Detect when application is closed

后端 未结 2 1944
小蘑菇
小蘑菇 2020-12-20 13:05

I want to know when the app is closed, because I need to erase a Database when the user shutdown the app, just in the moment when the user close the app is the right moment

2条回答
  •  自闭症患者
    2020-12-20 13:24

    Supposing you don't finish() your main activity, clearing your database inside the onDestroy() method of that activity might be the closest of what you want to accomplish. As has been pointed in the comments, refer to http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle.

提交回复
热议问题