Android: How to know if an activity is finished?

Try triggering those in the Activity lifecycle methods onStop or onDestroy. Check this documentation for more details.

onStop will be triggered when user clicks on back button. So handle your events in onStop.

public void onStop () {
//do your stuff here
super.onStop() 
}

Eventually onDestroy will also be called, but not necessarily as soon as the back button is clicked.

Leave a Comment