Reputation: 553
I have a requirement to be able to monitor my application's state each minute even if the application is not on top.
SO I am using TIME_TICK broadcast for this. However, when the application is not on top, I am not receiving the broadcast. But, when my application is running on top I am getting it.
Any work around for this?
Upvotes: 0
Views: 938
Reputation: 553
I tried TIME_TICK in every way possible. The thing with TIME_TICK is that it is only active when the application concerned is up and running. Yes we do have to explicitly register for the broadcast from a Activity. But, even after that though I didn't unregister when exiting from the app, I was not getting the broadcast(Since Activity was dead so mostly the Broadcast registration was gone).
The solution which worked for me in this case is using AlarmManager, by setting a setRepeat alarm for each minute.
Upvotes: 0
Reputation: 3692
I assume you are registering the receiver at your manifest.xml file.
as the Android Documentation says:
Broadcast Action: The current time has changed. Sent every minute. You cannot receive this through components declared in manifests, only by explicitly registering for it with Context.registerReceiver().
Upvotes: 1