Issue
Is it possible to differentiate between the following:
A. Activity is being re-created after having been destroyed by the OS. For instance, if the device has "Don't keep activities" enabled and the user sends my app to the background then brings it to the foreground again.
B. Activity is being re-created after an app crash.
Solution
I don't think there is a way as such but I don't believe that the onStop or OnDestroy is called when the activity crashes but not 100% sure.
If it doesn't, then in the onStop or onDestroy set a shared preference i.e. shutdownCorrectly which is set to true.
Then when the activity opens, check that the shared preference shutdownCorrectly run your normal code and set the shared preference to false. If the shared preference is false when you check, then it means the app crashed so you can run other code.
Hope this helps.
Answered By - Boardy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.