I have a android app to load multiple images from mysql database onto a ImageButton.
imageButton.setImageBitmap(fetchBitmap("http://www...~.jpg"));
I was once able to load png successfully but it also fails now (No success with jpg images ever). Here is the code I use for downloading images:-
public static Bitmap fetchBitmap(String urlstr) {
InputStream is= null;
Bitmap bm= null;
try{
HttpGet httpRequest = new HttpGet(urlstr);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
is = bufHttpEntity.getContent();
BitmapFactory.Options factoryOptions = new BitmapFactory.Options();
bm = BitmapFactory.decodeStream(is);
}catch ( MalformedURLException e ){
Log.d( "RemoteImageHandler", "Invalid URL: " + urlstr );
}catch ( IOException e ){
Log.d( "RemoteImageHandler", "IO exception: " + e );
}finally{
if(is!=null)try{
is.close();
}catch(IOException e){}
}
return bm;
}
I get this error:-
D/skia(4965): --- SkImageDecoder::Factory returned null
I have already tried various combinations as suggested here, here and several other solutions, but it doesnt work for me. Am I missing something? Image is definitely present in the web address I enter.
Thank you.