I have created an android application where image is loading from given url.When I am passing url directly, the image is loading. But image is not loading when I am taking the url inside a string variable and passing that variable . My code is given below .
private Drawable ImageOperations(String url, String saveFilename) {
try {
String realImageUrl=url+"? email="+Constants.email+"&proc_date="+Constants.proc_date+"&access_key="
+Constants.ACCESS_KEY+"&version=1.00";
String newUrl=realImageUrl.replace("https", "http");
InputStream is = (InputStream) this.fetch(newUrl);
Log.e("https,SubString http: ",realImageUrl+","+ a);
Drawable d = Drawable.createFromStream(is, "src");
return d;
} catch (MalformedURLException e) {
return null;
} catch (IOException e) {
return null;
}
}
public Object fetch(String address) throws MalformedURLException,
IOException {
URL url = new URL(address);
Object content = url.getContent();
return content;
}
This code is not working. my new url is newUrl. when I am printing newUrl in my log and giving that url directly instead of newUrl the image is loading.
I have found the solution. I have updated the fetch(String address) method.