PendingIntent getActivity Flag:
public static final int FLAG_CANCEL_CURRENT
Added in API level 1Flag indicating that if the described PendingIntent already exists, the current one should be canceled before generating a new one. For use with getActivity(Context, int, Intent, int), getBroadcast(Context, int, Intent, int), and getService(Context, int, Intent, int).
You can use this to retrieve a new PendingIntent when you are only changing the extra data in the Intent; by canceling the previous pending intent, this ensures that only entities given the new data will be able to launch it. If this assurance is not an issue, consider FLAG_UPDATE_CURRENT.
Constant Value: 268435456 (0x10000000)
public static final int FLAG_NO_CREATE
Added in API level 1
Flag indicating that if the described PendingIntent does not already exist, then simply return null instead of creating it. For use with getActivity(Context, int, Intent, int), getBroadcast(Context, int, Intent, int), and getService(Context, int, Intent, int).
Constant Value: 536870912 (0x20000000)
public static final int FLAG_ONE_SHOT
Added in API level 1
Flag indicating that this PendingIntent can be used only once. For use with getActivity(Context, int, Intent, int), getBroadcast(Context, int, Intent, int), and getService(Context, int, Intent, int).
If set, after send() is called on it, it will be automatically canceled for you and any future attempt to send through it will fail.
Constant Value: 1073741824 (0x40000000)
public static final int FLAG_UPDATE_CURRENT
Added in API level 3
Flag indicating that if the described PendingIntent already exists, then keep it but replace its extra data with what is in this new Intent. For use with getActivity(Context, int, Intent, int), getBroadcast(Context, int, Intent, int), and getService(Context, int, Intent, int).
This can be used if you are creating intents where only the extras change, and don't care that any entities that received your previous PendingIntent will be able to launch it with your new extras even if they are not explicitly given to it.
Constant Value: 134217728 (0x08000000)

本文详细介绍了Android中PendingIntent的常用标志,包括FLAG_CANCEL_CURRENT、FLAG_NO_CREATE、FLAG_ONE_SHOT和FLAG_UPDATE_CURRENT等,这些标志用于控制PendingIntent的行为,如更新现有的PendingIntent、取消现有实例及限制使用次数。
1978

被折叠的 条评论
为什么被折叠?



