答案 0 :(得分:1)
HttpClient was deprecated in API Level 22 and has been removed in API Level 23。您必须使用<picture>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/652/coffee5.jpg" srcset="https://s3-us-west-2.amazonaws.com/s.cdpn.io/652/coffee5.jpg" data-pin-description="Hello World">
</picture>
。
如果您在API 23中仍然需要,请将其添加到您的URLConnection
:
build.gradle
注意:相反,我建议使用OkHttp。
答案 1 :(得分:0)
试试这个......
InputStream irs;
URL url = new URL("**your URL**");
try{
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(30000);
conn.setConnectTimeout(45000);
conn.setRequestMethod("GET");
conn.setDoInput(true);
// Starts the query
conn.connect();
irs = conn.getInputStream();
}catch(Exception e)
{
e.printStactTrace();
}
答案 2 :(得分:0)
请导入这些课程。
可能会弃用 所以请将它添加到您的构建文件
依赖项{
编译文件(&#39; libs / org.apache.http.legacy.jar&#39;)
}