Android处理多个通知时不会发生冲突

Android处理多个通知时不会发生冲突,android,android-notifications,Android,Android Notifications,Im使用以下机制以避免向系统广播相同的通知Id int directInstallCompleteNotificationId = GlobalPrefUtils.getSharedPref().getSharedPrefsInt(PREF_NOTIFICATION_INSTALL_COMPLETE, 0); directInstallCompleteNotificationId++; GlobalPrefUtils.getSharedPref().setSharedPrefsInt(PRE

Im使用以下机制以避免向系统广播相同的通知Id

int directInstallCompleteNotificationId = GlobalPrefUtils.getSharedPref().getSharedPrefsInt(PREF_NOTIFICATION_INSTALL_COMPLETE, 0);

directInstallCompleteNotificationId++;

GlobalPrefUtils.getSharedPref().setSharedPrefsInt(PREF_NOTIFICATION_INSTALL_COMPLETE, directInstallCompleteNotificationId);

有没有办法让android处理id的增加?

将通知id作为
系统传递。currentTimeMillis()
,这将始终是唯一的,并且应用程序的通知之间不会发生任何冲突。

系统是否返回值。currentTimeMillis()永远不要超过允许的值?在我看来,发送多条相等的消息表明软件设计很差。我建议你重新设计你的结构,这样你的应用程序中的每个状态都只有一个不同的通知,如果需要的话,只发送一个不同的通知。