Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distinguish whether onDestroy will be called after onPause

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 onPause() when activity lost focus and when is going down and onDestroy() is gonna be called.

like image 789
esmeralda2 Avatar asked Nov 30 '22 17:11

esmeralda2


1 Answers

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 ;)

like image 103
Beasly Avatar answered Dec 02 '22 05:12

Beasly