创建新挂起的意图每一个在Android的时间意图、挂起、时间、Android

2023-09-05 01:38:20 作者:伤若堆成海

如何创建evertime挂起的意图。目前我的现有挂起的意图是越来越更换新的。我TRID使用FLAG_ONE_SHOT以及CANCEL_CURRENT,但没有奏效。

How do i create pending intent evertime. currently my existing pending intent is getting replaced with new one. I trid using FLAG_ONE_SHOT as well as CANCEL_CURRENT but it didn't work.

有人可以帮帮我吗?

谢谢 chintan

thanks chintan

推荐答案

添加一个随机数请求code这样的:

add a random number to the request code like that:

Intent intent = new Intent(context, YourClassname.class);
intent.putExtra("some data", "txt");  // for extra data if needed..

Random generator = new Random();

PendingIntent i=PendingIntent.getActivity(context, generator.nextInt(), intent,PendingIntent.FLAG_UPDATE_CURRENT);