How to debug onDestroy(), Android system kills app while paused in debugger

前端 未结 2 1180
闹比i
闹比i 2021-01-06 01:04

I have a bug I\'m trying to analyze that occurs when the Activity\'s onDestroy() method is called after hitting the back button. I\'ve put breakpoints in the offending code

2条回答
  •  忘掉有多难
    2021-01-06 01:13

    You can try a breakpoint on super.onDestroy(), but I suspect you'll have the same luck. :(

    Android won't let you linger in onDestroy, it will timeout, so try to accomplish your shutdown more quickly. onDestroy() is intended only for freeing resources and isn't always called before termination; data should be persisted in onPause() or onStop(). https://developer.android.com/training/basics/activity-lifecycle/stopping.html

    Addendum: Other options include using a background service for some of the work or to manually handle the back button to give yourself more time, but it could negatively impact user experience.

    http://www.stanford.edu/class/cs193a/03/

    sent from my phone, please cut my thumbs some slack.

提交回复
热议问题