I have one weird problem and I’m trying to solve it a couple of hours already. Problem is that this code below can decode all images except those one which have small first letter in name. For example, it’s working for Dog.png or 123.png but it doesn’t work for dog.png, cat.png or any other with small first letter. It just displays some random color for them. I’m confused. Any ideas?
Bitmap bitmap = null;
options.inJustDecodeBounds = false;
try {
bitmap = BitmapFactory.decodeStream((InputStream)new URL(imagePath).getContent(), null, options);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
image.setImageBitmap(bimage);
I found the solution. Pictures from those URL’s can be decoded but the problem was it was too big so it showed extremely enlarged and looked like it’s not showing.
First we need to catch description of image like this:
Then scale it to desired width/height, reqHeight/reqWidth are wanted size parameters:
After that just repeat that code from question:
Now we can save it to some directory:
Image in now saved and we can grab it and display in our ImageView called image: