[英]Android notifications overlap each other
我遇到了類似的問題,嘗試了各種方法。 我最終能夠使用sharedpreferences解決它。 盡管這不是一種相對流行的方法,但它很有幫助,因為您可以跟蹤發送的每個通知。 這是一個代碼片段:
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();
希望對您有所幫助。
為時已晚,但解決方案是不創建NotificationCompat.Builder的新實例,在每次通知更新中使用相同的生成器,以避免動畫重疊。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.