0
我使用上面的代码从我的虚拟主机获取信息。这很好奇,但该脚本在AVD中运行良好,但在我的真实设备(Samsung Galaxy Note)上却没有。它不会抛出任何异常。Android http发布在仿真器上,但不在我的真实设备上
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
}
LogCat中没有错误。它输出“打印1”,跳过try块中所有剩余的代码,调用此方法的类将抛出一个带有void消息的异常。 注意:我将uses-permission标签android.permission.INTERNET放在uses-sdk之后,并且在模拟器中正常工作。
请帮忙!