Dan*_*iel 38 android android-intent notificationmanager android-pendingintent
我有一个从通知栏打开的活动,但是当我这样做时NotificationManager.notify(...),我将意图赋予不同的捆绑,以便每个通知打开相同的活动,但从DB获取彼此的其他信息.
但是当我尝试输入任何通知时(例如有3个通知),它们都会将我发送到与最后一个相同的捆绑的活动.尝试使用一些Flags之后,我真的不知道问题出在哪里(一些标志使通知进入第一个包的活动).
我按照他们在教程中使用它的方式.
roc*_*dev 107
如果PendingIntent具有相同的操作,操作,数据,类别,组件和标志,则将替换它.
根据情况,我通常通过提供唯一的请求代码作为静态值(0,1,2)或我从数据库接收的数据的行ID来解决这个问题.
PendingIntent.getActivity(context, MY_UNIQUE_VALUE , notificationIntent, PendingIntent.FLAG_ONE_SHOT);
Run Code Online (Sandbox Code Playgroud)
然后我使用与notify()相同的唯一值
mNotificationManager.notify(MY_UNIQUE_VALUE, notification);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18744 次 |
| 最近记录: |