4

I'm noticing the tracking pending intents that I send out via the standard SmsManager in Android doesn't seem to retain the extra information in them. Example:

Intent sentIntent = new Intent(SENT);
sentIntent.putExtra("value1", "foo"); // <- note this value
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, sentIntent, 0);

SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(numberToSendTo, null, mMessageToSend, sentPI, null);

//... in the broadcastReceiver that catches the SENT intent ...
public void onReceive(Context arg0, Intent arg1) {

    arg1.getExtras().getString("value1");  // <- nothing, no such key
}

Can someone test this out, was this behaviour intended and I am doing it wrong, or is this a bug to be filed for Android?

Billy
  • 1,374
  • 1
  • 17
  • 25
  • The code is wrapping intent object into PendingIntent Object. the code puts value in intent object and not pending Intent object. So I suspect in you onReceive method you are getting the same intent object or Object of PendingIntent Class. – Relsell Apr 12 '12 at 06:17

1 Answers1

1

Try adding the flag FILL_IN_SELECTOR when you create the PendingIntent (see the spec for PendingIntent.getBroadcast for the flags and their general behavior). This should force the PendingIntent to take in all the top-level extras from the Intent.

Femi
  • 64,273
  • 8
  • 118
  • 148