Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect app crash in android

I'm building an app that sometimes crashes, I want to know that it crashed in the next time I opened it so I can suggest to the user some post-crash options. How can I detect the crash? Also I want to be able to save the user's work before it crashes, I means real time detection of crash, can I do it without knowing where it crashed?

like image 437
alon Avatar asked Sep 20 '15 12:09

alon


2 Answers

You will need to know where it crashed in order to set the try/catch blocks in the right place to, er, catch the crash and save the data or whatever you have in mind.

This is known as "graceful" termination if you want to consider it in more detail.

Unfortunately neither Java destructor/finalize methods nor lifecycle methods such as onDestroy are anywhere near as robust as try/catch blocks so I'm afraid that is your only option, and how many of us deal with exception prevention. No-one would wittingly provide a user experience that crashes, much less with loss of their data.

like image 78
John Avatar answered Sep 19 '22 13:09

John


Take a took at the ACRA library. You can configure it so whenever a crash happens you can control it and even send the crash log by email

like image 44
Alberto S. Avatar answered Sep 21 '22 13:09

Alberto S.