How to determine if one of my activities is in the foreground [duplicate]

The following answer: “Is application running in background“, summarizes solutions available for background/foreground checking.

Note:
Previously this answer suggested to use ActivityManager.getRunningAppProcesses(), however that method appeared to be not completely reliable and its usage is discouraged. Check the link above for the details.

Leave a Comment