安卓 notification 使用pendingintent传值时传值重复或无效的问题
来源:互联网 发布:淘宝补单靠谱吗? 编辑:程序博客网 时间:2024/06/07 06:02
intent, PendingIntent.FLAG_UPDATE_CURRENT);
pendingintent.getactivity方法中第二个参数和第4个参数会影响intent中extras的内容 第二个值是id 相当于这个pendingintent的标签 同一个标签的pendingintent只会显示最新的 intent也是最新的intent 第4个参数会影响intent的extras的内容 这里常用的flag标签如下
FLAG_ONE_SHOT:this PendingIntent can only be used once. 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.
FLAG_NO_CREATE:if the described PendingIntent does not already exist, then simply return null instead of creating it.
FLAG_CANCEL_CURRENT:if the described PendingIntent already exists, the current one is canceled before generating a new one. 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.
FLAG_UPDATE_CURRENT: if the described PendingIntent already exists, then keep it but its replace its extra data with what is in this new Intent. 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.
其中FLAG_UPDATE_CURRENT是最常用的 描述的Intent有更新的时候需要用到这个flag去更新你的描述,否则组件在下次事件发生或时间到达的时候extras永远是第一次Intent的extras。使用FLAG_CANCEL_CURRENT也能做到更新extras,只不过是先把前面的extras清除,FLAG_CANCEL_CURRENT和FLAG_UPDATE_CURRENT的区别在于能否新new一个Intent,FLAG_UPDATE_CURRENT能够新new一个Intent,而FLAG_CANCEL_CURRENT则不能,只能使用第一次的Intent。
- 安卓 notification 使用pendingintent传值时传值重复或无效的问题
- 安卓 Notification的使用
- Notification和PendingIntent的结合使用
- 安卓Notification.Builder的使用
- 安卓组件---Notification 的使用
- pendingintent重复问题
- Notification使用以及PendingIntent.getActivity()
- Notification使用以及PendingIntent.getActivity()
- Notification 中PendingIntent 只打开最后一个Intent的问题
- 安卓学习:(5)安卓Notification的使用
- Notification和NotificationManager的使用(一)以及pendingintent详解
- translate3d在安卓无效的问题
- Notification中PendingIntent的陷阱
- cordova项目中local-notification插件的使用问题及解决(安卓平台)
- 【安卓笔记】notification使用
- 安卓 Notification使用笔记
- 【安卓笔记】PendingIntent
- 安卓5.0以上系统notification中setTicker无效
- struts2(三)---struts2中的服务端数据验证框架validate
- leetcode:Reorder List
- 获取webview的高度
- Oracle常用总结
- 输入框被键盘遮挡问题
- 安卓 notification 使用pendingintent传值时传值重复或无效的问题
- Java序列化
- android Activity生命周期
- 不同数据库下的可更新结果集问题
- xcode 4 导入Lib,Framework的方法,和Undefined symbols for architecture x86_64:的一种解决办法
- java----for 与 for-each
- ViewPager的用法
- Kafka->SparkStreaming
- Android ViewPager+Fragment 模式中 Fragment的返回键的处理