这是我发出http请求的示例代码,但它没有这样做。这是我在 LogCat 中看到的错误日志。http://pastebin.com/56AL8Dxu
我也在<uses-permission android:name="android.permission.INTERNET"></uses-permission>
清单中添加了。请帮帮我..在Android中发出一个简单的http请求真的那么难吗?我来自.Net背景学习Android开发。
void testHTTP()
{
HttpClient httpClient = new DefaultHttpClient();
HttpUriRequest request = new HttpPost("http://www.google.com");
try {
HttpResponse response = httpClient.execute(request);
//System.out.println("response protocol version: " + response.getProtocolVersion());
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}