本人在使用android Studio编写网站展示的应用程序中,使用HttpClient httpClient = new DefaultHttpClient();获取客服端时,编译器显示没有HttpClient这个类。网上查资料,换成CloseableHttpClient httpclient = HttpClients.createDefault();也同样没有类CloseableHttpClient 这个类。上面两个类都是被deprecated了。
请问android Studio 1.2.1.1这个版本,实现http协议GET数据的接口是哪个?在哪个包?
方案推荐指数:2
HttpURLConnection
conn.setRequestMethod(“GET”);
包的话应该是:import java.net.HttpURLConnection; sdk带了
方案推荐指数:2
HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("http://localhost/"); HttpResponse response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); int l; byte[] tmp = new byte[2048]; while ((l = instream.read(tmp)) != -1) { } }
方案推荐指数:2
方案推荐指数:4
方案推荐指数:2
导的包对?
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.util.EntityUtils;
方案推荐指数:2
我的androidstudio/lib里面也有httpclient-4.3.6.jsr,可是就是解析不出来这个
import org.apache.http.NameValuePair
这里显示红色
我在另一台机的1.0版本的Androidstudio就能解析出来
这个好像不用另外配置引入jar的吧
方案推荐指数:2
http://zhidao.baidu.com/link?url=3tuI0uLDjh89Cc2N06y1kK8q2Bcut45qNb-U7xmd4pkvj0WWDIkRaT-iuyCpH0qN2Q4OqwapqnwMiJjq1eihnMpmEhnx6eUATZaPNAgdCsa