更新时间:2023-01-14 23:20:26
每个通知必须有自己的通知 ID.
Each Notification must have its own Notification ID.
您的问题在这里:
notificationManager.notify(0, notification);
具体来说,0"是通知的ID.如果您不提供不同的 ID,Android 会认为您只是在更新已经存在的通知.
Specifically, the "0" is the ID of the Notification. If you do not provide a different ID, Android will think you are simply updating the Notification that already exists.
文档.
public void notify (int id, Notification notification)
发布要在状态栏中显示的通知.如果通知您的应用程序已经发布了具有相同 ID 的尚未取消,将以更新的信息代替.
Post a notification to be shown in the status bar. If a notification with the same id has already been posted by your application and has not yet been canceled, it will be replaced by the updated information.
你可以尝试这样的事情:
You could try something like this:
private int mCounter = 0;
...
notificationManager1.notify(++mCounter, notification1);