How to know in BroadcastReceiver if App is running on foreground?
问题 I am working in application that needs make a synchronization every night. I use Alarm Manager that calls a BroadcastReceiver at the hour that I want. The problem is that I cant make a synchronization if the application is running in foreground to avoid losing data. So I need to know in Broadcast Receiver if the app is running in foreground to cancel this synchronization. I tried solutions that I found in StackOverflow: Checking if an Android application is running in the background But this