I have a question about Android application status. I want to know that am I able to check whether application is alive or dead, visible or on background. I need to make a decision according to application status in my broadcast receiver.
Thanks in advance..
Basically, when your receive broadcast your application is guaranteed to run. That’s because broadcast can not be received without application process started first. And if there were no components active (like activities) when broadcast is sent, then application process is started for the sole purpose of processing this broadcast.
As for the other part, detecting if any Activity is currently active and/or visible – I haven’t seen any API calls for this. There are might be some workaround (like manually keeping the counter in a singleton), but as far as I know there is no direct support for this. Though I might be wrong.