android用来管理通知,Android:管理多个通知

Chander Shivdasani

9

java

android

我正在尝试在我的应用程序中创建多个通知.为了唯一地识别每个通知,我给了他们一个唯一的identifyId.以下是我的代码:

private void updateNotification(int notificationId, int clockStatusID, CharSequence text) {

//notificationManager.cancel(notificationId);

// throws up an ongoing notification that the timer is running

Log.i("TIMERCOUNT", "Notification id: " + notificationId);

Notification not = new Notification(clockStatusID, // the

// icon

// for

// the

// status

// bar

text, // the text to display in the ticker

System.currentTimeMillis() // the timestamp for the

// notification to appear

);

Intent intent = new Intent();

intent.putExtra("notificationID", notificationId);

intent.setAction("actionstring" + System.currentTimeMillis());

intent.setClassName("com.chander.time.android.activities",

"com.chander.time.android.activities.Tabs");

not.setLatestEventInfo(self,

getText(R.string.timer_notification_title),

getText(R.string.timer_on_notification_text), PendingIntent

.getActivity(this, 0, intent,

PendingIntent.FLAG_UPDATE_CURRENT));

not.flags += Notification.FLAG_ONGOING_EVENT;

not.flags += Notification.FLAG_NO_CLEAR;

notificationManager.notify(notificationId, not);

}

问题:选择通知时,会调用Tabs活动传递意图.我想访问在选项卡中选择的通知的唯一notificationId.我尝试使用intent.putExtra()将notificationId保存在intent中.但是,对于多个通知,它会覆盖notificationId并返回最新的通知.我不明白为什么会发生这种情况,我怎么能避免覆盖notificationId.

谢谢,Chander

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值