Extended Application class - Force Close on Restart Android

前端 未结 1 1842
感情败类
感情败类 2021-01-26 17:59

I have my AppMain class [My class Name] that extended the Application class in my app. That have some Globals. I have mentioned inside the manifest. an

相关标签:
1条回答
  • 2021-01-26 18:48

    The app isn't actually running if it isn't consuming processor time (either running a service or presenting an Activity to the user). It may be in memory but Android's memory management model is designed that way and the app will be killed if something else needs the memory. onPause is a good indication that you may soon exit, and onDestroy should free up any resources that an exit button would.

    If you absolutely must exit, you can use finish() instead, and/or try using the excludeFromRecents or noHistory flags in the manifest to avoid the crash. There should be a few others you can play around with, too.

    See this question and the Process Lifecycle section of the developer docs.

    0 讨论(0)
提交回复
热议问题