HTTP GET例外目标主机不能在ICS空 [英] Http get exception Target host must not be null on ICS

查看:176
本文介绍了HTTP GET例外目标主机不能在ICS空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到的ICS此异常,而2.2是运行良好。

  java.lang.IllegalStateException:目标主机不能为空,或参数进行设置。方案= NULL,主机= NULL,路径= HTTP://maps.googleapis.com/maps/api/geo$c$c/json经纬度= 32.0692342,34.7952296&放​​大器;传感器=真的吗?

下面是我的code:

  HTTPGET请求=新HTTPGET(URLEn coder.en code(requestUrl,UTF-8));
        HTT presponse响应;
        响应= mHttpClient.execute(请求);


解决方案

删除 URLEn coder.en code 通话,它不需要

这是需要为en code中的URL参数,例如:

 字符串的URL = \"http://maps.googleapis.com/maps/api/geo$c$c/json?latlng=\"+URLEn$c$cr.en$c$c(\"32.0692342,34.7952296\")+\"&sensor=\"+URLEn$c$cr.en$c$c(\"true\")

I am getting this exception on ICS, while on 2.2 it is running fine.

java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=http://maps.googleapis.com/maps/api/geocode/json?latlng=32.0692342,34.7952296&sensor=true

Here is my code:

        HttpGet request = new HttpGet(URLEncoder.encode(requestUrl, "UTF-8"));
        HttpResponse response;
        response = mHttpClient.execute(request);

解决方案

Remove the URLEncoder.encode call, it is not needed

It is needed to encode the url parameters, for example:

String url = "http://maps.googleapis.com/maps/api/geocode/json?latlng="+URLEncoder.encode("32.0692342,34.7952296")+"&sensor="+URLEncoder.encode("true")

这篇关于HTTP GET例外目标主机不能在ICS空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆