I have pending intent to show message status after send
private void sendSMS(String phoneNumber, String message)
{
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
}
This is my pending intent
deliveredPI = PendingIntent.getBroadcast(this, id, new Intent(DELIVERED), 0);
When sms is delivered, I want to get requestcode
from PendingIntent
to show which sms is delivered, but in onReceive()
method I can't get requestcode
You should add your SMS id
to the PendingIntent
like this:
Intent deliveryIntent = new Intent(DELIVERED);
deliveryIntent.putExtra("id", id);
deliveredPI = PendingIntent.getBroadcast(this, id, deliveryIntent, 0);
Then, in onReceive()
you can get the SMS id like this:
int id = intent.getIntExtra("id", -1);
if (id >= 0) {
// Got a valid id...
}