解决Notification PendingIntent意图打开Activity数据没有更新的问题
来源:互联网 发布:网络教育和函授含金量 编辑:程序博客网 时间:2024/05/19 18:44
在使用Notification通知时,如果没有设置PendingIntent.FLAG_UPDATE_CURRENT就会出现在通知栏点击第二条通知时还是第一条的通知的数据,以下解释:
8. PendingIntent中定义了几个FLAG。
(1) android.app.PendingIntent.FLAG_UPDATE_CURRENT
如果PendingIntent已经存在,保留它并且只替换它的extra数据。
int android.app.PendingIntent.FLAG_UPDATE_CURRENT = 134217728 [0x8000000]
Flag for use with getActivity, getBroadcast, and getService: 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.
代码:
Context context = getApplicationContext(); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.jpush_notification_icon, "南方有道", System.currentTimeMillis()); notification.flags = Notification.FLAG_AUTO_CANCEL; //点击后自动消失 Intent intent = new Intent(this,TestActivity.class); intent.putExtra("message", msg); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, "标题", msg, pendingIntent); notificationManager.notify(0, notification);
- 解决Notification PendingIntent意图打开Activity数据没有更新的问题
- Android 通知PendingIntent意图打开Activity,数据无更新? 解决方法
- notification PendingIntent跳转数据不更新问题
- Notification 中PendingIntent 只打开最后一个Intent的问题
- Notification&PendingIntent 发现问题+解决+思考
- 总结:AppWidget Notification PendingIntent Activity...
- Notification(二)——PendingIntent的flag导致数据相同的问题
- Android 通知PendingIntent意图发送广播,但Intent数据无更新? 解决方法
- Android状态栏通知(notification)和PendingIntent传值(解决传值总是获取第一次的值的问题)
- Android状态栏通知(notification)PendingIntent传值(解决传值总是获取第一次的值的问题)
- Notification内的Intent Extra数据不能更新的问题
- Notification内的Intent Extra数据不能更新的问题
- Notification内的Intent Extra数据不能更新的问题
- android使用意图打开activity的两种方式
- 如何防止PendingIntent打开一个Activity的多个实例
- 解决在拍照之后,Media数据没有及时更新问题
- VX中解决在绑定数据后没有及时更新的问题
- Notification中PendingIntent的陷阱
- sed命令详解
- 上三角形数组转换为一维数组
- Canvas绘图android机器人
- Tomcat:如何解决Address already in use: JVM_Bind错误?
- ADO_NET_基础
- 解决Notification PendingIntent意图打开Activity数据没有更新的问题
- 的3网站地址
- 推荐文章2
- rac目录权限导致重启失败(转)
- Java NIO Buffer
- zookeeper常用命令
- oracle中的左右连接
- xcode5创建支持ios5的应用
- UIPickerView控件 1