Android进阶2之Http操作访问网络
操作步骤:
<1>
生成请求对象
HttpGet httpGet = new HttpGet("请求地址。。。。。");
<2>
生成客户端对象
HttpClient httpClient = new DefaultHttpClient();
<3>
执行请求
HttpResponse httpResponse = httpClient.execute(httpGet);
<4>
接受响应
HttpEntity httpEntity = httpResponse.getEntity();
<5>得到数据流
InputStream inputStream = httpEntity.getContent();
注意:
要添加权限: <uses-permission android:name="android.permission.INTERNET" />
具体实现: