Broadcastreceiver Not Firing On Notification Action Click
I am trying to create a simple notification with a button (action) defined to it. I have managed to display it properly and create a PendingIntent for my action. I have also create
Solution 1:
First, if you are going to use .MainActivity$Receiver, then Receiver needs to be a static class.
Second, dismissIntent is (redundantly) using action1 as the action string, but the <intent-filter> uses com.example.orglce.notification.BROADCAST. These do not match. I recommend getting rid of the <intent-filter>, getting rid of the action1, and using new Intent(this, Receiver.class) to create an explicit Intent to identify your BroadcastReceiver.
Solution 2:
Your manifest has problem. You add action to your notification intent with this name "action 1" you should edit your action name in MainActivity like this:
Intent dismissIntent = newIntent("com.example.orglce.action1");Edit your receiver like this:
<receiverandroid:name=".MainActivity$Receiver"><intent-filter><actionandroid:name="com.example.orglce.action1" /></intent-filter></receiver>Finally edit your if in broadcast receiver like this:
if (whichAction.equals("com.example.orglce.action")) {
MainActivity.makeToast("This is action 1", context);
}
Post a Comment for "Broadcastreceiver Not Firing On Notification Action Click"