[英]How to detect that an app is shutdown vs. suspended
我怎么能檢測到一個應用程序真的是關閉/被終止還是被掛起(.Suspending/.Suspended)?
我只需要在應用程序最終被終止時觸發一些代碼(如果有的話)。
提前致謝
當應用程序被殺死時調用:
@Override
protected void onDestroy() {
super.onDestroy();
}
當應用程序暫停時調用:
@Override
protected void onPause() {
super.onPause();
}
Application.Suspending
事件(例如在 iOS 上)在應用程序被掛起時被引發。
在OnLaunched
方法期間,您通常無法可靠地確定應用程序是否被OnLaunched
,並且只能在應用程序重新啟動時執行某些操作。 您應該假設您的應用程序可能會在調用Suspending
終止。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.