How to identify that the application has stopped working?

Asked

Viewed 157 times

0

I need to save some data every time the application closes, I did this by overriding the onStop, onDestroy, onPause and works, under normal conditions, more when the crash, he does not perform any of these override and consequently does not save the data I need.

It would have as I identify that the app stopped working (crashed)?

  • I find it difficult, because in the case of crash, no event is triggered... a solution would be to make a periodic save, like emails or applications like Word, hence when loading the App, it is possible to recover this data.

1 answer

3


The best way is to identify the most sensitive crash points in your app and treat them with Try/catch blocks, so you can save data at these points.

try{
  // Executa código "sensível" a travamentos
} catch {
  // Salva os dados da aplicação
}

In addition, as already suggested, do Periodic Observations, including in onDestroy, onPause, etc., as you have already done.

There is no "Liener" for crashes on the SDK, so you will have to do these treatments whenever possible.

EDIT: You can try this suggestion to create a custom Handler of exceptions they gave in this question in Stackoverflow:

https://stackoverflow.com/questions/37256595/how-to-have-a-callback-for-when-a-crash-occurred-while-using-crashlytics-sdk

Browser other questions tagged

You are not signed in. Login or sign up in order to post.