Why the PendingIntent doesn't send back my custom Extras setup for the Intent?

后端 未结 5 733
甜味超标
甜味超标 2020-12-01 13:51

This questions somehow relates to the question when I was looking to get the extras back in startActivityForResult but now I face another challenge.

I have subscribe

5条回答
  •  暖寄归人
    2020-12-01 14:40

    None of the answers worked for me. Setting action to a specific string works for the first time but if you use the same notification with different extras at a later time, it would not work. I replaced the string for the setAction method with a randomly generated one and it works without any issues:

    intent.setAction(new Random().nextInt(50) + "_action");
    
    • If you think that you might use the notification a lot (Like for downloading different files) then pass a larger number to nextInt()

提交回复
热议问题