我正在尝试请求HTTP,但它在我身上奄奄一息
HttpResponse httpResponse = httpClient.execute(httpGet);
以下是我的代码......
public JSONObject getJSONFromUrl(String url) {
// HTTP Request
try {
// defaultHttpClient
System.out.println("CRAZY1");
HttpClient httpClient = new DefaultHttpClient();
System.out.println("CRAZY2");
HttpGet httpGet = new HttpGet(url);
System.out.println("CRAZY3");
System.out.println("CRAZY4");
HttpResponse httpResponse = httpClient.execute(httpGet);
System.out.println("CRAZY5");
HttpEntity httpEntity = httpResponse.getEntity();
System.out.println("CRAZY6");
is = httpEntity.getContent();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
它告诉我线程正在退出未捕获的异常。我确实在清单中启用了权限。可能是什么问题?
答案 0 :(得分:0)
确保您的网址包含http://,否则HttpGet的构造函数将抛出IllegalArgumentException。