android Notification跳转 getIntent()问题

来源:互联网 发布:生死狙击矩阵视频 编辑:程序博客网 时间:2024/06/05 07:03

今天写IM推送,点击Notification跳转至聊天界面时,getIntent()始终获取到的是第一次点击notification时候传递过来的Intent.
问题出现的原因,是PendingIntent初始化参数问题。

错误代码

    PendingIntent intent = PendingIntent.getActivity(context,0,                notificationIntent, 0);

这里写图片描述

我们主要看 requestCode这个参数,Google文档的解释是:发件人私有的请求码
请求码一样,getIntent()获取到的就是一样的。
所以改变requestCode的值即可

0 0