I had a similar problem and I tried all sorts of methods. I was eventually able to solve it using sharedpreferences . Although this isn't a relatively popular way of doing this, it helps because you can keep track of every notification sent. Here's a code snippet:
SharedPreferences prefs = getSharedPreferences(Activity.class.getSimpleName(), Context.MODE_PRIVATE);
int notificationNumber = prefs.getInt("notificationNumber", 0);
notificationManager.notify(notificationNumber, notification);
SharedPreferences.Editor editor = prefs.edit();
notificationNumber++;
editor.putInt("notificationNumber", notificationNumber);
editor.commit();
I hope this helps.. Merry coding!!!
为时已晚,但解决方案是不创建NotificationCompat.Builder的新实例,在每次通知更新中使用相同的生成器,以避免动画重叠。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.