Incorrect extras received with all intents but the first one

本小妞迷上赌 提交于 2019-12-05 00:24:37

Try adding FLAG_UPDATE_CURRENT to your PendingIntent when you create it via getBroadcast().

The above answers are correct, but they lack an explanation. It's worth noting this part of the PendingIntent documentation:

A PendingIntent itself is simply a reference to a token maintained by the system describing the original data used to retrieve it. ... If the creating application later re-retrieves the same kind of PendingIntent (same operation, same Intent action, data, categories, and components, and same flags), it will receive a PendingIntent representing the same token

Note that "extra" data is specifically not included in the concept of PendingIntent-identity!

best Link I've found on this topic: http://alvinalexander.com/source-code/android/android-how-attach-extra-intent-pendingintent-notification-solution-example

this is the clue:

int uniqueInt = (int) (System.currentTimeMillis() & 0xfffffff);
PendingIntent.getService(context, uniqueInt, intent, 0)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!