I have an IntentService that is refreshing data from a server (no push notifications) once an hour. If there's any new data it's supposed to either update the interface when inside the app or send a notification when my app is not in the foreground. My question would be: How do I determine which app is running in the foreground or easier if my app is running in the foreground? I don't need to know what Activity that is just the general package name of my app is totally fine!
Two things I've found so far which I'd oppose to use:
- ActivityManager.getRunningTasks() - it's been deprecated and as mentioned by Google might break in the future
- UsageStats - Seems nice but it's really inconvenient if the user has to give my app UsageStats rights.
I'm a little bit confused why I'm not able to find a solution for that..I thought this wasn't a unusual practice or whatever.
Thanks!