Android 获取不到远程数据

jpang 发布于 2015/05/06 17:46
阅读 93
收藏 0

public void onClick(View v) {

TextView tv_1 = (TextView) findViewById(R.id.tv1);
String httpUrl = "http://www.517yueye.com/android.aspx";
HttpGet httpRequest = new HttpGet(httpUrl);
try {
HttpClient httpclient = new DefaultHttpClient();
HttpResponse httpResp /> // 请求成功
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
// 取得返回的字符串
String strResult = EntityUtils.toString(httpResponse
.getEntity());
tv_1.setText(strResult);  //问题就是这里取不到数据
} else {
tv_1.setText("请求错误!");
}

} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {

e.printStackTrace();
}

}

加载中
0
亓斌哥哥
亓斌哥哥
你在ui线程访问网络了, error
返回顶部
顶部