I’m doing an HTTP request in an Android application using this code:
try
{
HttpPost post = new HttpPost(<URL>);
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity();
String responseText = EntityUtils.toString(entity);
parseResponce(responseText);
}
catch (Exception e)
{
Log.e("http post error : ", e.getMessage());
}
The request is working on android 2.3, but I’m not receiving a response in Android 4.0.4.
Why not?
I guess you’re having troubles because you perform network operation on UI thread. Try using AsyncTask or Java threading framework.