I’m using the code above to get information from my web host. It’s curious, but the script works fine in the AVD but not on my real device (Samsung Galaxy Note). It doesn’t throw any exception.
try{
HttpClient htClient = getHttpClient();
HttpPost htPost = new HttpPost("http://myworkingurl/access.php");
Log.i("MyLog", "Print 1"); // this is outputed to LogCat
HttpResponse htResponse = htClient.execute(htPost);
Log.i("MyLog", "Print 2"); // no output here
} catch (ClientProtocolException ce) {
Log.i("MyLog", ce.getMessage()); // no output here
} catch (IOException e) {
Log.i("MyLog", e.getMessage()); // no output here
}
No error in LogCat. It outputs “Print 1”, jumps over all remaining code in the try block, and the class that call this method throws a exception with a void message.
Note: I’d put the uses-permission tag android.permission.INTERNET after uses-sdk and works fine in the emulator.
Please, help!
You better try the same code in an asyncTask. It may be because of the strict mode.