Android HttpPost Crash, Can't Debug? -


device xoom tablet. reason can't httppost, when try can't trap error. tried bunch of basic examples , crashed out same way (see stack trace). attach manifest in case missed permission. know it's happening in client.execute(post); statement. error not trapped , see in stack trace below. have tried bunch of different ways can't life of me tell real error is. post data not seem matter, same thing happens simple httpget request. on earth missing?

block in question

try {                 httpclient client = new defaulthttpclient();                 httppost post = new httppost("http://share1.iqperspective.com/test");                 list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>();                 namevaluepairs.add(new basicnamevaluepair("avar", "test data"));                 post.setentity(new urlencodedformentity(namevaluepairs));                 client.execute(post);              }catch (unsupportedencodingexception e1) {                 log.v(tag, "catch1");             }catch (clientprotocolexception e) {                 log.v(tag, "catch2");             }catch (ioexception e) {                 log.v(tag, "catch3");             } 

mainifest

<?xml version="1.0" encoding="utf-8"?>   <manifest xmlns:android="http://schemas.android.com/apk/res/android"   package="com.quisenberry.iqperspective"   android:versioncode="1"   android:versionname="1.0"> <uses-sdk android:minsdkversion="11" /> <application android:icon="@drawable/img_icon" android:label="@string/app_name">     <activity android:name="iqperspective" android:label="@string/app_name">         <intent-filter>             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity> </application>  <uses-permission android:name="android.permission.camera" /> <uses-permission android:name="android.permission.internet"></uses-permission> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" /> </manifest> 

the stack

thread [<1> main] (suspended (exception networkonmainthreadexception))   defaultrequestdirector.execute(httphost, httprequest, httpcontext) line: 530     defaulthttpclient(abstracthttpclient).execute(httphost, httprequest, httpcontext) line: 555  defaulthttpclient(abstracthttpclient).execute(httpurirequest, httpcontext) line: 487     defaulthttpclient(abstracthttpclient).execute(httpurirequest) line: 465  iqperspective$13.onclick(view) line: 294     button(view).performclick() line: 3100   view$performclick.run() line: 11644  viewroot(handler).handlecallback(message) line: 587  viewroot(handler).dispatchmessage(message) line: 92  looper.loop() line: 126  activitythread.main(string[]) line: 3997     method.invokenative(object, object[], class, class[], class, int, boolean) line: not available [native method]   method.invoke(object, object...) line: 491   zygoteinit$methodandargscaller.run() line: 841   zygoteinit.main(string[]) line: 599  nativestart.main(string[]) line: not available [native method]   

i think name of exception (networkonmainthreadexception) tells what's going on. need execute networking code on non-ui thread. see article painless threading more info.

this new honeycomb. see docs exception more info.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -