httpclientget网络请求数据
来源:互联网 发布:新开淘宝店卖什么好 编辑:程序博客网 时间:2024/06/10 12:03
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.btnRead).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new Thread(){
@Override
public void run() {
super.run();
httpClientGet();
}
}.start();
}
});
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.btnRead).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new Thread(){
@Override
public void run() {
super.run();
httpClientGet();
}
}.start();
}
});
}
private void httpClientGet(){
HttpClient httpClient=new DefaultHttpClient();
HttpGet httpGet=new HttpGet("http://v.juhe.cn/WNXG/city?key=ed1088c0c4ac34c42a270fabf0de9b5a");
try {
HttpResponse httpResponse=httpClient.execute(httpGet);
int code = httpResponse.getStatusLine().getStatusCode();
if (code== HttpStatus.SC_OK){
InputStream is = httpResponse.getEntity().getContent();
String str = StreamTools.transForm(is);
Log.w("=====", str);
}
} catch (IOException e) {
e.printStackTrace();
}
}
HttpClient httpClient=new DefaultHttpClient();
HttpGet httpGet=new HttpGet("http://v.juhe.cn/WNXG/city?key=ed1088c0c4ac34c42a270fabf0de9b5a");
try {
HttpResponse httpResponse=httpClient.execute(httpGet);
int code = httpResponse.getStatusLine().getStatusCode();
if (code== HttpStatus.SC_OK){
InputStream is = httpResponse.getEntity().getContent();
String str = StreamTools.transForm(is);
Log.w("=====", str);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
0 0
- httpclientget网络请求数据
- 通过 httpclientget 方法 向服务器中请求数据
- HttpClientGet
- HttpClientGET
- 网络数据请求
- qml 请求网络数据
- 网络请求数据解析
- iOS网络数据请求
- 请求网络数据JSON
- 网络请求数据
- 网络请求数据
- 网络数据请求
- 网络异步请求数据
- IOS_UI_网络数据请求
- 从网络请求数据
- 网络数据的请求
- iOS_UI_网络数据请求
- http,请求网络数据
- JSON 与 对象 、集合 之间的转换
- Spring Boot学习笔记(零) 前言
- Search a 2D Matrix
- 357. Count Numbers with Unique Digits
- HDU 5818 Joint Stacks 栈模拟
- httpclientget网络请求数据
- mysql 2
- 双系统Ubuntu无法访问windows磁盘分区解决方法
- 自定义两个圆环一直转
- leetcode 338 Counting Bits
- Java反射基础
- Jquery相关层次选择器
- 四连通与八连通
- yii查询相关