I develop android application and every thing is right no error but when I run the code i found this error below and when I track the code it's stop on this line :
HttpResponse httpResponse = httpClient.execute(httpPost);
the part of the code :
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
Log.d("w", "2a json...................");
HttpResponse httpResponse = httpClient.execute(httpPost);
Log.d("w", "2b json...................");
HttpEntity httpEntity = httpResponse.getEntity();
Log.d("w", "2c json...................");
is = httpEntity.getContent();
Log.d("w", "3 json...................");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
the errors:
threadid=1: thread exiting with uncaught exception (group=0x410702a0)
FATAL EXCEPTION: main
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
at libcore.io.IoBridge.connect(IoBridge.java:112)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
at java.net.Socket.connect(Socket.java:842)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)