Trying to ID the SMS delivery confirmation

怎甘沉沦 提交于 2019-11-29 18:25:42

Your problem is due the fact that PendingIntents can be reused by the system, if certain things about the requests are not different. In your code, you're passing FLAG_UPDATE_CURRENT, which is causing the stored Intent and its extras to be updated each time a PendingIntent is requested. This is why you're getting id : 3 for each of the messages. To correct this, you can call getBroadcast() with a unique request code (the second parameter) each time, which will create a new PendingIntent for each request, each with a separate Intent with their own extras.

In your case, the fix should be simple, assuming that idSms is unique for each message.

PendingIntent sentPI = PendingIntent.getBroadcast(getApplicationContext(),
                                                  Integer.parseInt(idSms),
                                                  sentIntent,
                                                  PendingIntent.FLAG_UPDATE_CURRENT);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!