Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Http get exception Target host must not be null on ICS

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);
like image 495
meh Avatar asked Dec 27 '22 16:12

meh


1 Answers

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")
like image 127
Daniel Fekete Avatar answered Jan 02 '23 16:01

Daniel Fekete