I essentially only want a GCM notification to be put in the notification tray if the user is outside of my application. What is the easiest way to check if the user is currently inside of the application? Thanks in advance
Asked
Active
Viewed 92 times
2
-
The other question seems to be a duplicate, but the the answers will only work if: 1. "You are in an activity and not a receiver" 2. "You can tell if the application is running, but not necessarily in the foreground" – stacksonstacksonstackoverflow Sep 27 '13 at 18:53
-
@GuyLeStack, see the second answer in the duplicate link. – ozbek Sep 27 '13 at 18:58
-
The answer by Gadenkan would only seemingly tell you if the app is running. Not whether or not your app is running in the foreground or background. Correct? – stacksonstacksonstackoverflow Sep 27 '13 at 19:01
-
_Then check with the first task(task in the foreground)_ --- the first task in the returned list is the foreground app. If that's yours, then you are in foreground, otherwise in background. – ozbek Sep 27 '13 at 19:12
-
Gotcha. Will try that out. Thanks – stacksonstacksonstackoverflow Sep 27 '13 at 19:26