I am currently trying to get the confirmation for each sended SMS. I need to be sure that my SMS are send, so I used a BroadCastReceived
to get the information
Your problem is due the fact that PendingIntent
s 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);