Is Activity in Foreground Android?
Contents How Do You Know If an Activity Is in the Foreground? in Your Finish() Method, You Want to Use isActivityVisible() to Check If the Activity Is Visible...
Contents
How do you know if an activity is in the foreground?
In your finish() method, you want to use isActivityVisible() to check if the activity is visible or not. There you can also check if the user has selected an option or not. Continue when both conditions are met.
Must Read
Which is not state of an activity in Android?
2.1. States of an activity
| State | Description |
|---|---|
| Stopped | Activity is not visible, instance is running but might be killed by the system. |
| Killed | Activity has been terminated by the system of by a call to its finish() method. |