Skip to content Skip to sidebar Skip to footer

Java Android , Httpget Error - Host Name May Not Be Null

I am using HttpGet to get the contents of some images. It has worked well but now it gives me errors with a new server I am using which returns images on the form of: https://amx-s

Solution 1:

Did you encode URI? For example remove spaces or other special characters that break stuff? Try android.net.Uri.encode(String s)

HttpGet mHttpGet = new HttpGet(new URI(null,android.net.Uri.encode(item.getImageUrl()),null));

Best way to debug this to always print the URL and analyze the ones that give an error.

Solution 2:

I think you are using the wrong constructor. The three argument URI constructor has this signature:

public URI(String scheme, String ssp, String fragment)

but you are providing a URL as the 2nd argument rather than an SSP. I think you should be using the one argument constructor that takes a URL string as its argument.

Solution 3:

Well there was no Java or Android problem, it results that the server changes the request when it comes from a device...

Solution 4:

Please try a host name without the use of hyphens "-" or underscores "_", see if it works .

Post a Comment for "Java Android , Httpget Error - Host Name May Not Be Null"