开发者

How to distinguish whether onDestroy will be called after onPause

开发者 https://www.devze.com 2023-02-06 10:26 出处:网络
Is there any way how to distinguish whether onDestroy() will be called after onPause()? In may activity I need to do different action when Activity lost focus and when Activity is going down, but even

Is there any way how to distinguish whether onDestroy() will be called after onPause()? In may activity I need to do different action when Activity lost focus and when Activity is going down, but even when activity is going down onPause() is called before onDestroy() I want to do different action in onPaus开发者_开发技巧e() when activity lost focus and when is going down and onDestroy() is gonna be called.


Yes with:

@Override
protected void onPause() {
    super.onPause();
    if (this.isFinishing()) {
         // WAHT YOU WANT TO DO BEFORE DESTROYING...
    }
}  

But of course it can't handle if your app crashs ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消