Android HttpPost Crash, Cant Debug?
Device is a Xoom Tablet. For some reason I cant do a HttpPost, when I try I cant trap the error. I tried a bunch of basic examples and they all crash out the same way (see stack trace). I will attach my manifest in case I missed a permission. I know its happening in the client.execute(post); statement the error is not trapped and all I get is what you see in the stack trace below. I have tried a bunch of different ways but I cant for the life of me tell what the real error is. The post data does not seem to matter, same thing happens with a simple HttpGet request. What on earth am I 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]	

Android HttpPost Crash, Cant Debug?
===

Device is a Xoom Tablet. For some reason I cant do a HttpPost, when I try I cant trap the error. I tried a bunch of basic examples and they all crash out the same way (see stack trace). I will attach my manifest in case I missed a permission. I know its happening in the client.execute(post); statement the error is not trapped and all I get is what you see in the stack trace below. I have tried a bunch of different ways but I cant for the life of me tell what the real error is. The post data does not seem to matter, same thing happens with a simple HttpGet request. What on earth am I 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]	
