Hi folks,
I've written an app, thats loading images either using the android gallery app or by taking a photo using the cam.
When I now load an image using the gallery, everything is fine. When the code is being executed a second time (for loading another image), the application crashes.
try {
Uri data = intent.getData();
ContentResolver cr = this.getContentResolver();
Bitmap mBitmap = null;
mBitmap = Media.getBitmap(cr, data);
imageView.setImageBitmap(mBitmap);
} catch(Exception e){
showToast(this, "Failed loading image from gallery");
return;
}
The code crashes at the line mBimap = Media.getBitmap(cr, data);
. Everything is initialized, there are no null values etc. The strange thing is: no exception is thrown, I don't get into the catch block to determine whats going wrong.
Does anyone have an idea about this? Am I not allowed to "re-use" the content resolver? Do I have to free it after the first usage or something like this?