httpclientpost网络获取数据
来源:互联网 发布:淘宝店铺怎么上众划算 编辑:程序博客网 时间:2024/06/06 20:00
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();
getMenu("ed1088c0c4ac34c42a270fabf0de9b5a");
}
}.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();
getMenu("ed1088c0c4ac34c42a270fabf0de9b5a");
}
}.start();
}
});
}
private void getMenu(String key){
HttpClient httpClient=new DefaultHttpClient();
HttpPost httpPost=new HttpPost("http://v.juhe.cn/WNXG/city");
List<BasicNameValuePair> list=new ArrayList<BasicNameValuePair>();
list.add(new BasicNameValuePair("key",key));
try {
httpPost.setEntity(new UrlEncodedFormEntity(list));
HttpResponse httpResponse=httpClient.execute(httpPost);
int code = httpResponse.getStatusLine().getStatusCode();
if (code== HttpStatus.SC_OK){
InputStream is = httpResponse.getEntity().getContent();
String str = StreamTools.transForm(is);
Log.w("=====", str);
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
HttpClient httpClient=new DefaultHttpClient();
HttpPost httpPost=new HttpPost("http://v.juhe.cn/WNXG/city");
List<BasicNameValuePair> list=new ArrayList<BasicNameValuePair>();
list.add(new BasicNameValuePair("key",key));
try {
httpPost.setEntity(new UrlEncodedFormEntity(list));
HttpResponse httpResponse=httpClient.execute(httpPost);
int code = httpResponse.getStatusLine().getStatusCode();
if (code== HttpStatus.SC_OK){
InputStream is = httpResponse.getEntity().getContent();
String str = StreamTools.transForm(is);
Log.w("=====", str);
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
0 0
- httpclientpost网络获取数据
- HttpClientPost
- HttpClientPOST
- 获取网络数据
- 获取网络数据
- 获取网络数据
- 网络交互,获取数据
- 网络数据获取
- 获取网络数据
- Android获取网络数据
- android获取网络数据
- 网络数据获取
- 网络数据获取 调试
- HttpClient获取网络数据
- react网络数据获取
- android获取网络数据
- HTTPUTILS获取网络数据
- 网络请求 获取数据
- hdu5971 Wrestling Match(染色法判二分) 2016ACM/ICPC亚洲区大连站
- Tensorflow学习: RNN-LSTM应用于MNIST数据分类
- 《Cracking the Coding Interview程序员面试金典》----下一个元素(下一个比他大的)
- HDU
- fasterxml如何对Java枚举类型做类型转换
- httpclientpost网络获取数据
- [Android] Android Studioの打包问题
- rpm,diff,patch,grep,cut,sort,tr
- QT小知识点(3) -Qt Creator 使用技巧之提高编译速度【使用jom参数】
- Windows中hosts文件的位置
- myeclipse:could not create..异常处理
- 图的储存之邻接表
- 笔记
- 8