android httpGet请求,红色部分很关键,可能这种方式不是最好的。
来源:互联网 发布:月工资算法公式 编辑:程序博客网 时间:2024/06/05 23:57
android httpGet请求,红色部分很关键,可能这种方式不是最好的。
@SuppressLint("NewApi")
public void SendData() {
// TextView resultText = (TextView) this.findViewById(R.id.resultText);
String httpUrl = "http://www.baidu.com/s?wd=123";
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
// 创建httpRequest对象
HttpGet httpRequest = new HttpGet(httpUrl);
try
{
// 取得HttpClient对象
HttpClient httpclient = new DefaultHttpClient();
// 请求HttpClient,取得HttpResponse
HttpResponse httpResponse = httpclient.execute(httpRequest);
// 请求成功
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
// 取得返回的字符串
String strResult = EntityUtils.toString(httpResponse.getEntity());
Log.d("strResult", "strResult" + strResult);
}
else
{
Log.d("error", "error");
}
}
catch (ClientProtocolException e)
{
Log.d("error", "error" + e.getMessage().toString());
}
catch (IOException e)
{
Log.d("error", "error" + e.getMessage().toString());
}
catch (Exception e)
{
Log.d("error", "error" + e.getMessage().toString());
}
}
0 0
- android httpGet请求,红色部分很关键,可能这种方式不是最好的。
- Android中两种请求方式HttpGet和HttpPost验证用户登录
- java最简单的方式实现httpget和httppost请求
- android的两种网络请求方式关键代码详解
- android httpget httppost 请求,超时参数的设置
- Android httpget 请求遭遇路径的非法字符
- HttpPost,HttpGet,HttpPut,HttpDelete请求方式
- 对于携带请求参数的HttpGet与的HttpPost两种请求方式,代码段分析
- 3 关键问题可能不是出在技术上
- 关键问题可能不是出在技术上
- 可能是互联网从业者最好的娱乐方式
- httpget请求
- HttpGet请求
- 测试用例或许不是了解产品的最好方式
- android 提交httpGet和httpPost请求
- android平台HttpGet、HttpPost请求实例
- Android平台HttpGet、HttpPost请求实例
- Android平台HttpGet、HttpPost请求实例
- 微信公众平台获取用户信息
- 如何从零开始学习JavaEE
- Java的环境变量配置的方法
- Java8的lambda(3)
- CSS3简明教程-1.1.CSS3是什么
- android httpGet请求,红色部分很关键,可能这种方式不是最好的。
- 在IOS开发中使用GoogleMaps SDK
- java分词器大全
- 传真服务器软件产品的选择
- RedHat5.4系统下载及中文设置
- FFmpeg Protocols Documentation
- 将java的值传到javascript中
- IOS应用之间调用跳转
- SqlServer替换text类型数据解决方案