我有这个功能:
public String getUrl(String url) {
HttpClient httpclient = new DefaultHttpClient();
String html = "";
try {
CookieStore cookieStore = new BasicCookieStore();
HttpContext localContext = new BasicHttpContext();
localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
HttpGet httpget = new HttpGet(url);
// Pass local context as a parameter
HttpResponse response = httpclient.execute(httpget, localContext);
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(in));
StringBuilder str = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
str.append(line);
}
in.close();
html = str.toString();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
httpclient.getConnectionManager().shutdown();
return html;
}
}
问题是,这些函数永远不会返回任何字符(我已经用google.de尝试过了)。可悲的是,结果总是空的。
寻求帮助
答案 0 :(得分:0)
我的猜测(我只能猜测你提供的信息):
您忘记了清单中的互联网权限。