【发布时间】:2012-10-31 22:14:31
【问题描述】:
我正在为 Android 编写一个应用程序。应用程序连接到服务器以检索 cmets。 感兴趣的代码是:
BufferedReader input = null;
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.domain.com/personal_proj/directorydirectory/file.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
Log.i("TEST","after httpclient.execute()");
HttpEntity entity = response.getEntity();
我在 HTC Wildfire 和 HTC Desire Z 中测试了这段代码,它可以工作。如果此代码在 Android 4.0+ 中执行,则永远不会到达该行
Log.i("TEST","after httpclient.execute()");
,服务器永远不会收到请求,也永远不会抛出异常。
有什么想法吗?
【问题讨论】:
标签: android httpclient