我正在创建一个多站计时应用程序,其中将有多个计时器并行运行,并且每个通知都绑定到每个计时器。Android:在状态栏中管理多个通知
我可以使用下面的代码创建多个计时器。
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.setClassName("com.intuit.time_catcher.android.activities",
"com.intuit.time_catcher.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);
}
以下是im面临的问题。 考虑在状态栏中有3个计时器正在运行并且有3个通知。当我更新计时器2时,通知3(位于最右端)得到更新,但我真正想要做的是更新第二个通知(中间一个)。 当我打印通知ID的时候,即时看到正确的值。 我无法理解为什么我得到这种奇怪的行为?
我试过了,但我仍然得到相同的问题 – 2010-08-06 22:39:04
而不是intent.setAction()我用intent.setData()和它的工作 – 2010-08-12 17:36:44