我有一个通知,每三秒钟就会刷新(即发送)。我已经设置了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 吗? - Gyan aka Gary Buyn