Sent/delivered SMS: how do you identify to which SMS the broadcast belongs?

Mathias Referring to the code in the question you linked. When you create the Intent to be launched by the PendingIntent instead of just giving it an Action String you can add an extra to it to help determine which SMS it belongs to Intent sentIntent = new Intent(SENT); sentIntent. PutExtra("smsNumber", someValue); PendingIntent sentPI = PendingIntent.

GetBroadcast(this, 0, sentIntent, FLAG_UPDATE_CURRENT); Intent deliveredIntent = new Intent(DELIVERED): deliveredIntent. PutExtra("smsNumber", someValue); PendingIntent deliveredPI = PendingIntent. GetBroadcast(this, 0, deliveredIntent, FLAG_UPDATE_CURRENT) This way you should be able to retrieve the "smsNumber" value inside the BroadcastReceiver Hope this helps!

Edit by Mathias Lin: Important that you pass the flag FLAG_UPDATE_CURRENT with the pending intent, so that the extras get passed along and actually arrive with the broadcast.

Mathias, Referring to the code in the question you linked. When you create the Intent to be launched by the PendingIntent instead of just giving it an Action String you can add an extra to it to help determine which SMS it belongs to... Intent sentIntent = new Intent(SENT); sentIntent. PutExtra("smsNumber", someValue); PendingIntent sentPI = PendingIntent.

GetBroadcast(this, 0, sentIntent, FLAG_UPDATE_CURRENT); Intent deliveredIntent = new Intent(DELIVERED): deliveredIntent. PutExtra("smsNumber", someValue); PendingIntent deliveredPI = PendingIntent. GetBroadcast(this, 0, deliveredIntent, FLAG_UPDATE_CURRENT); This way you should be able to retrieve the "smsNumber" value inside the BroadcastReceiver Hope this helps!

Edit by Mathias Lin: Important that you pass the flag FLAG_UPDATE_CURRENT with the pending intent, so that the extras get passed along and actually arrive with the broadcast.

Thanks for that tip, it does make sense. However, I tried it, but when I read out the relevant extra from the intent (second parameter in onReceive of the broadcast receiver), it's null. In fact, the intent.getExtras().size() is still 0.

Seems that the extras are not passed along all the way to through the pending intent and broadcast. – Mathias Lin May 8 at 3:19 1 Note: you need to pass FLAG_UPDATE_CURRENT to the pending intent, in order for the extras to be passed along. Otherwise, the extras won't arrive with the broadcast.

– Mathias Lin May 8 at 5:26 @Mathias Lin If you put FLAG_UPDATE_CURRENT you will vanish all you extras in previous Intents. And if one of messages will be delivered only the last sms will be pointed as delivered (even if it isn't) – Maxim Jul 29 at 11:49 The solution that worked for me (not so elegant thought) was to use different Action strings for each message. – Maxim Jul 29 at 12:00.

It is described how you can monitor the status of a sent/delivered SMS via broadcast. However, I haven't found: how do you identify to which SMS the broadcast belongs? There doesn't seem to be any information in getResultData() nor getResultExtras() as far as I have checked.

My use case is: I send multiple SMS in a loop one right after another.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions