Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BroadcastReceiver when application is not running

I have a BroadcastReceiver registered in the manifest which receives notifications from the AlarmManager. This all works great while the app is running i.e. the onReceive() method is being called.

However, if I force-stop the app so that I can test if the BroadcastReceiver will still receive notifications from the AlarmManager while not running, the onReceive() method is never called.

Can force-stop not be used to test the AlarmManager & receiver in this way? There seems to be some responses saying it won't work, and some saying it should.

If not, is there a way of testing this?

like image 479
jFort Avatar asked Oct 07 '22 18:10

jFort


1 Answers

If your receiver is registered in your manifest, it should always work. Even if your app is force closed.

The problem might be the alarm. The alarms might be getting deleted, once your app force closes.

like image 188
Kumar Bibek Avatar answered Oct 12 '22 12:10

Kumar Bibek