How to prevent Android App from crashing abruptly <p>I know this is a very broad question on how to prevent an Android app from crashing. I understand there could be many reason behind the app crashing. </p> <p>Primarly my app crashed because of 2 main reasons :- </p> <p>1) Out of memory while taking pictures and storing byte array in memory. I also uses bitmap to redraw the image captured.</p> <p>2) Camera issues. App has a feature of autofocusing on touch events and while actually taking the pictures. These autofocus often crashes into each other. I have handled it using cancelling any existing autofocus code and discarding any further on touch events using flags once the picture is being captured. But still some time app crashes due to unknow reason.</p> <p>There may be more reason behind app crashes. So my question is </p> <p>1) Is there a way I can identify that app has crashed and handle that event so that instead of just showing the messsage ""UnForunately App has stopped working. Force Close." I can give a better user friendly message to user and stop the app programatically.</p> <p>2) If out of memory every happens, is there a way I can identify that my App is running low on allocated memory and I can handle the scenario. OnLowMemory will give the low memory status of entire device, not just my application. I use lot of cache to store the images &amp; heap for bitmap. </p> <p>3) If the camera ever crashes (because of any reason), is there a way I can handle the scenario.</p> <p>Thanks in advance. Gagan</p>