Skip to content Skip to sidebar Skip to footer

Encode Image Url From Spaces

I'm developing a RSS reader app, but I'm facing problems with the image URLs becuase they contain spaces. I tried several techniques from these forums but they all give me differen

Solution 1:

StringurlStr="http://abc.dev.domain.com/0007AC/ads/800x480 15sec h.264.mp4";
URLurl=newURL(urlStr);
URIuri=newURI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
url = uri.toURL();

Related: Bad URL encoding for images

Solution 2:

Remove both :

conn.setDoInput(true);
conn.setDoOutput(true);

Hope this should solve the problem.

Solution 3:

Try this technique

Stringquery= URLEncoder.encode("apples oranges", "utf-8");
Stringurl="http://stackoverflow.com/search?q=" + query;

Or use something like

Stringuri= Uri.parse("http://...")
                .buildUpon()
                .appendQueryParameter("key", "val")
                .build().toString();

Post a Comment for "Encode Image Url From Spaces"