If you want to take any step before the Activity
becomes invisible.
There are several options here.
onDestroy () - for final cleaning.
isFinishing () - immediately after calling act.finish()
it will return true.
onStop () - when Activity
killed by the framework process. (not destroyed)
onPause () - when an Activity
covered by any other Activity
onBackPressed () - capture of the hardware key Back event caused by the user.
Adil soomro
source share