Search code examples
javaandroidandroid-intentandroid-activity

How to know activity has been finished?


I want to check to see if an activity is running or finished. Is there any method through which I can check the status of activity?

I found activity.isFinishing() but I am not sure about it.


Solution

  • If you want to perform any step before Activity is going to become invisible.

    Their are several choices here.

    onDestroy() - for final cleanup.

    isFinishing() - right after act.finish() is called it will return true.

    onStop() - when the Activity is killed by framework process. (not destroyed)

    onPause() - when the Activity is covered by any other Activity

    onBackPressed() - capturing the event of hardware Back key triggered by user.