【发布时间】:2011-05-31 15:20:54
【问题描述】:
我有一个每三秒刷新(即发送)一次的通知。我已经设置了 FLAG_ONGOING_EVENT 标志和 FLAG_NO_CLEAR 标志,以便始终显示。问题是,如果例如下载处于活动状态(在通知区域中显示进度条)两个通知会不断切换位置,因为它们都每隔几秒刷新一次。
如何将我的通知固定到列表顶部(或某个静态位置),以便在我每次调用NotificationManager.notify() 更新它时它停止跳动?
编辑:这是更新通知的代码。它每三秒运行一次。
Notification notification = new Notification();
notification.contentView = appBarNotification; // this sets the changed notification content
notification.flags |= Notification.FLAG_ONGOING_EVENT;
notification.flags |= Notification.FLAG_NO_CLEAR;
Intent notificationIntent = new Intent();
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.contentIntent = contentIntent;
notification.icon = R.drawable.icon;
nm.notify(APP_BAR_NOTIFICATION, notification);
【问题讨论】:
-
你每次拨打
notify()时使用相同的ID吗? -
是的,我就是这么做的。我将在问题中发布相应的代码。
标签: android notifications