My app crashes when decoding file using BitmapFactory

215 Views Asked by At

I have an app that has multiple activities. Those activities contain an imageview that loads an image from a specified path on the phone (DCIM/Camera/Pic123.jpg), by using BitmapFactory.decodeFile(). The problem is, is that if I close out of the activities in and out really quickly, the app crashes!

File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/camera/TapTrack");
File file;
file = new File(picturesDirectoryPath, "TapTrack_164.jpg"); 
imageView.setImageBitmap(BitmapFactory.decodeFile(file.getAbsolutePath()));

the app crashes on this line 4th line of code. So my question is, does anyone know any way I can make the decodeFile process more efficient? Or are there any alternatives to the BitmapFactory?

0

There are 0 best solutions below