android弹出顶部通知,android – 通知区域的顶部通知

  • Post author:
  • Post category:其他


我有三秒钟的刷新(即发送)的通知.我设置了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);