7

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?

alon
  • 121
  • 1
  • 1
  • 7

5 Answers5

4

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.

John
  • 6,433
  • 7
  • 47
  • 82
3

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

Alberto S.
  • 7,409
  • 6
  • 27
  • 46
1

You can use try/catch blocks, then send details on the Exception in your catch.

PPartisan
  • 8,173
  • 4
  • 29
  • 48
1

There are implement UncaughtExceptionHandler as mentioned in these answers and write crash report in some file or use it another way.

Community
  • 1
  • 1
Krupal Shah
  • 8,949
  • 11
  • 57
  • 93
1

ACRA is already mentioned.

However for paid version, I found BugSnag is very good at this. Or if you want to take the extra mile, try AppSee.

AppSee even has video recording session of how the crash happens. It is from tapping that button on the second list, the menu button or even when the user slides left in your viewpager.

Parag Jadhav
  • 1,853
  • 2
  • 24
  • 41
Fadils
  • 1,508
  • 16
  • 21