开发者

Android Notification Delete

I have developing an App where the user can create event and set notification for that very event. I am using the following code.

final Notification notifyDetails = new Notification(R.drawable.icon, "Myapp",calendar.getTimeInMillis());
Context context = getApplicationContext();
Intent notifyIntent = new Intent(context, ViewDoughnut.class);
PendingIntent pendingIntent = PendingIntent.getActivity(ViewCal.this, 0, notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
notifyDetails.setLatestEventInfo(context, 开发者_StackOverflowcontentTitle, contentText, pendingIntent);
notifyDetails.flags = Notification.FLAG_ONGOING_EVENT;
mNotificationManager.notify(eventId, notifyDetails);

I want to delete any specific notification if the user delete the event corresponding to it. I have tried with following code.

mNotificationManager.cancel(eventId);

But it is not working at all. How to do it?


see

http://developer.android.com/guide/topics/ui/notifiers/notifications.html#ManageYourNotifications

and

http://developer.android.com/reference/android/app/NotificationManager.html#cancel%28int%29

i used the tag to cancel my notifications:

int IdFromNotification = intent.getIntExtra("myId", -1);
NotificationManager nManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nManager.cancel(IdFromNotification + "", IdFromNotification);

needless to say that i used the same tag when setting the notification!?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜