Results 1 to 8 of 8
  1. #1
    chunk is offline Member
    Join Date
    Jun 2012
    Posts
    3
    Rep Power
    0

    Angry Android App Crashs

    im searching from 3 days for the answer but could not find it. So im here for help

    i want to use this code to post data to my server on php script.

    But when i call this function by button click the app closes by displaying the message below


    Unfortunately, MyApp has Stopped


    Java Code:
    	    public void postData() {
    
    	        //Create a new HttpClient and Post Header
    	        HttpClient httpclient = new DefaultHttpClient();
    	        HttpPost httppost = new HttpPost("http://www.site.com/android/save.php");
    	  
    	         try {
    	             // Add your data
    	             List <NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
    	             nameValuePairs.add(new BasicNameValuePair("id", "12345"));
    	             nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
    	             httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    
    	             // Execute HTTP Post Request
    	             HttpResponse response = httpclient.execute(httppost);
    	             
    	         } catch (ClientProtocolException e) {
    	             // TODO Auto-generated catch block
    	         } catch (IOException e) {
    	             // TODO Auto-generated catch block
    	         } 
    	 
    	}
    Moderator edit: added code tags
    Last edited by DarrylBurke; 06-30-2012 at 08:24 PM. Reason: Code tags

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Android App Crashs

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    chunk is offline Member
    Join Date
    Jun 2012
    Posts
    3
    Rep Power
    0

    Default Re: Android App Crashs

    i tried to put code in [code] tags but it was not displaying the full line of code thats y i removed it. you can see in logs i edited by post twice

    Anyone else please help me. I not getting the reason :-( and looking for it from past few days

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Android App Crashs

    Again, consider doing something with your exceptions -- at least printing out the stack trace.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Android App Crashs

    Quote Originally Posted by chunk View Post
    i tried to put code in [code] tags but it was not displaying the full line of code
    Really?

    Quote Originally Posted by chunk View Post
    thats y i removed it.
    Please spell words in full, and use uppercase letters where appropriate. This is a technical forum, not SMS chat.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    chunk is offline Member
    Join Date
    Jun 2012
    Posts
    3
    Rep Power
    0

    Default Re: Android App Crashs

    Quote Originally Posted by Fubarable View Post
    Again, consider doing something with your exceptions -- at least printing out the stack trace.
    im really new to java and working on it only for android app. And new to eclipse also i can not help myself in this matter. Can you please tell me what i can do?

    Quote Originally Posted by DarrylBurke View Post
    Really?
    Please spell words in full, and use uppercase letters where appropriate. This is a technical forum, not SMS chat.
    db
    look at the screenshot and try to improve

    Android App Crashs-1.jpgAndroid App Crashs-2.jpg

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,950
    Rep Power
    19

    Default Re: Android App Crashs

    Here's the Oracle tutorial on Java Exceptions.
    That should get you into a position to do the right thing with your catch blocks.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. JNI on Android
    By moriya in forum Android
    Replies: 1
    Last Post: 05-31-2012, 04:34 PM
  2. Android with JNI
    By gaurav115 in forum Android
    Replies: 1
    Last Post: 04-13-2012, 12:10 PM
  3. Replies: 1
    Last Post: 12-24-2011, 04:41 AM
  4. Android USB
    By Blackberrylerner in forum Android
    Replies: 0
    Last Post: 01-15-2011, 05:05 AM
  5. Android
    By sspkiet in forum Android
    Replies: 1
    Last Post: 09-03-2010, 01:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •