简体   繁体   中英

How to detect that an app is shutdown vs. suspended

How could I detect that an app really is shutdown/killed vs. being suspended (.Suspending/.Suspended)?

I needed to trigger some code only as the app ultimately is killed (if ever).

Thanks in advance

Called when app is being killed:

 @Override
protected void onDestroy() {
    super.onDestroy();
}

Called when app is being paused:

@Override
protected void onPause() {
    super.onPause();
}

The Application.Suspending event (eg on iOS ) is raised when the application is being suspended.

You generally cannot determine reliably if the app is being killed, and can only do something when the app restarts, during the OnLaunched method. You should assume that your app may be terminated once Suspending has been invoked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM