0

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?

NathanWick
  • 87
  • 1
  • 10
  • Can you post your logcat output? – daentech Nov 26 '14 at 22:35
  • Not exactly, because my app uses the camera heavily, I have to run it from my phone every time. So when it crashes, it's on my phone rather than on the AVD. – NathanWick Nov 26 '14 at 22:38
  • You'd still get a stacktrace in `adb logcat` – daentech Nov 26 '14 at 22:39
  • Where would I view it then? Do I need to install something? – NathanWick Nov 26 '14 at 22:41
  • Using both Eclipse and Android Studio you should see a log whenever your app is running. Also, if you have the SDK downloaded, from a terminal window in the `platform-tools` folder you can run `adb logcat` when your device is plugged in – daentech Nov 26 '14 at 22:42
  • To get logcat see: http://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this – Morrison Chang Nov 26 '14 at 22:43
  • How big is that file? You will have an out of memory error. Resize the image before putting it in an ImageView. Try your code with a very small jpg first. – greenapps Nov 26 '14 at 22:45
  • The file is the default size of a picture taken on the camera. I'm assuming that's way too big? – NathanWick Nov 26 '14 at 23:50

0 Answers0