How to know whether an application(not activity) running in background or not???
I am developing an alarm application. There are three activities A,B,C. A is the main app screen. User moves B from A. When B comes to foreground the alarm is registered. When B is finished the alarm is removed. When the receiver receives the notification from AlarmManager it invokes the Activity C. In C user can snooze stop the alarm.
My problem is when my application go to background, it should not ring the alarm. I want to remove the registered alarm. I can't override the B's onPause to remove the registered alarm because when the receiver receives the notification from alarm manager it invokes C to foreground and B moves to background. If i un-register the alarm in onPause of B, it will not ring in this scenario.
How to know the application is running in background (none of activities are in foreground) and then prevent invoking the C.
Thanks in advance