Notification Not Getting Removed On Clicking Action Button Even After Providing The Notification Id
Solution 1:
Assuming getNotificationService() == getNotificationNewRequestService()
Looks like the NotificationARBroadcastReceiver isn't called before the notfication is built and displayed.
You would do better to generate the notification id where you create the notification and just add it to the intent there as well you don't need to make.
So call getNotificationNewRequestService() from NotificationARBroadcastReceiver.recieve() and make sure the notification ids match up.
Solution 2:
Edit:
move:
m = (new Random()).nextInt(10000);
before:
actionIntent.putExtra("id", NotificationARBroadcastReceiver.m); // this will be 'm'
Result:
int m = (newRandom()).nextInt(10000);
Intent actionIntent = newIntent(getBaseContext(), MyBroadcastSender.class);
actionIntent.putExtra("id", m);
Log.d(getClass().getSimpleName(), "Notification Id is : " + m);
then, you can check what values are in id
, id1
and id2
. Don't forget to call .notify()
with same Id you got from m
.
You can, also, create getRandomNotificationId()
and getLastGeneratedNotificationId()
methods. Whenever you generate an Id, store it in public static
integer variable, so that you can access it throughout the class.
Problem might be that you are accessing m
from NotificationARBroadcastReceiver
before initializing it. So, it will definitely be 0
. And, you mentioned something about println
error, are you using System.out.println()
?
Before Edit:
As seen on your new edit, try closing notification before starting it:
m = (...);
// some code here
mNotifyMgr.cancel(m);
mNotifyMgr.notify(m, notification);
and see if your issue gets resolved.
Post a Comment for "Notification Not Getting Removed On Clicking Action Button Even After Providing The Notification Id"