//连接
HttpGet request = new HttpGet(url);
HttpClient client = new DefaultHttpClient();
HttpResponse response = null;
try {
response = client.execute(request); //4.0 SDK机子运行时会报错,android.os.NetworkOnMainThreadException
//访问成功
if(response.getStatusLine().getStatusCode()==HttpStatus.SC_OK){
//获取返回值
result = EntityUtils.toString(response.getEntity()).trim();
HttpGet request = new HttpGet(url);
HttpClient client = new DefaultHttpClient();
HttpResponse response = null;
try {
response = client.execute(request); //4.0 SDK机子运行时会报错,android.os.NetworkOnMainThreadException
//访问成功
if(response.getStatusLine().getStatusCode()==HttpStatus.SC_OK){
//获取返回值
result = EntityUtils.toString(response.getEntity()).trim();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货