Android的多个通知 [英] Android Multiple Notification

查看:154
本文介绍了Android的多个通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个应用程序,用户可以为非常事件创建事件和设置通知。所以我想添加多个通知。我现在用的是下面的code。

I have developing an App where the user can create event and set notification for that very event. So I want to add multiple notification. 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, contentTitle, contentText, pendingIntent);
notifyDetails.flags = Notification.FLAG_ONGOING_EVENT;
mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);

当我添加事件,并使用上述code创建一个通知,它工作正常。但是,如果我添加另一个事件,在没有新的通知,旧的是刚刚更新。我想增加一个通知。怎么做?此外,我想删除任何具体通知,如果用户删除与之相对应的事件。它是如何可能?

When I add an event and creating a notification using the above code, it is working fine. But if I add another event, no new notification created, the old one is just updated. I want to add one more notification. How to do it? Moreover, I want to delete any specific notification if the user delete the event corresponding to it. How it is possible?

推荐答案

我认为 SIMPLE_NOTIFICATION_ID 是一个常数?有单独通知,你需要使用不同的ID为每一个。

I assume that SIMPLE_NOTIFICATION_ID is a constant? To have separate notifications you need to use a different ID for each one.

这篇关于Android的多个通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆