Skip to content Skip to sidebar Skip to footer

Broadcastreceiver From Alarmmanager Not Getting Called

I have a class that extends IntentService. The stuff in this class is called when my app reboots (and also on app startup). It loads some settings and does some stuff in the backgr

Solution 1:

I modified my manifest to take multiple action (real actions, rather than pseudo-actions that I was doing via addExtra).

<receiverandroid:name="com.mycompany.myapp.Controller"><intent-filter><actionandroid:name="com.mycompany.myapp.Controller.START"/></intent-filter><intent-filter><actionandroid:name="com.mycompany.myapp.Controller.END" /></intent-filter></receiver>

Then, when I add the alarms with the Intent, I make sure to call setAction, specifying the String action. In the onReceive of the BroadcastReceiver I call getAction() (returns a String). And voila! Both alarms fire off as intended, and I can get the type of action and perform my associated methods.

Note: Answered with the help of @Chitrang (via comments to the question). Pointed out that the Intent was getting canceled because there was already an alarm scheduled for the IntentSender.

Post a Comment for "Broadcastreceiver From Alarmmanager Not Getting Called"