我编写的应用程序必须通过url-request显示页面内容(文本和图像)。我的任务需要手动完成,例如 WebView webView.loadUrl(url.toString()); 等变体不适用。如何以另一种方式解决这个问题?
答案 0 :(得分:1)
尝试使用HTTPClient
。像这样的东西。
public static InputStream getInputStreamFromUrl(String url) {
InputStream content = null;
try {
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(new HttpGet(url));
content = response.getEntity().getContent();
} catch (Exception e) {
Log.("[GET REQUEST]", "Network exception", e);
}
return content; //url content is here.
}