How to distinguish whether onDestroy will be called after onPause

Is there a way to tell if onDestroy() be called after onPause() ? In May activity, I need to do different actions when activity lost focus and when activity decreases, but even when activity decreases, onPause() is called before onDestroy() I want to perform different actions in onPause() , when the loss of focus activity and when it goes down , and onDestroy() will be called.

+4
source share
1 answer

Yes with:

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

But, of course, it cannot handle it if your application crashes;)

+20
source

Source: https://habr.com/ru/post/1336993/


All Articles