Results 1 to 8 of 8
Thread: Android App Crashs
- 06-29-2012, 11:44 PM #1
Member
- Join Date
- Jun 2012
- Posts
- 3
- Rep Power
- 0
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
Moderator edit: added code tagsJava 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 } }Last edited by DarrylBurke; 06-30-2012 at 08:24 PM. Reason: Code tags
-
Re: Android App Crashs
Um,... the first thing I would do would be to not ignore exceptions.
- 06-30-2012, 11:21 AM #3
Re: Android App Crashs
Why do they call it rush hour when nothing moves? - Robin Williams
- 06-30-2012, 06:18 PM #4
Member
- Join Date
- Jun 2012
- Posts
- 3
- Rep Power
- 0
-
Re: Android App Crashs
Again, consider doing something with your exceptions -- at least printing out the stack trace.
- 06-30-2012, 08:24 PM #6
- 07-01-2012, 09:25 PM #7
Member
- Join Date
- Jun 2012
- Posts
- 3
- Rep Power
- 0
- 07-02-2012, 10:58 AM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
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.
Similar Threads
-
JNI on Android
By moriya in forum AndroidReplies: 1Last Post: 05-31-2012, 04:34 PM -
Android with JNI
By gaurav115 in forum AndroidReplies: 1Last Post: 04-13-2012, 12:10 PM -
Android SDK 4.0.3 on a device with Android 2.3
By j2me64 in forum AndroidReplies: 1Last Post: 12-24-2011, 04:41 AM -
Android USB
By Blackberrylerner in forum AndroidReplies: 0Last Post: 01-15-2011, 05:05 AM -
Android
By sspkiet in forum AndroidReplies: 1Last Post: 09-03-2010, 01:14 AM


LinkBack URL
About LinkBacks
Reply With Quote



Bookmarks