In my app i am sending multiple sms at one time which working perfectly fine. But when i am trying to receive confirmation messages in Broadcast Receiver i am expecting to get all numbers but i end up in receiving same one number instead of n numbers.
To send SMS
Intent intent = new Intent(SENT);
intent.putExtra("phonenumber", sms_phonenumber);
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
SmsManager sms_man = SmsManager.getDefault();
sms_man.sendTextMessage(sms_phonenumber, null, sms_message, sentPI, null);
To Receive Sent Confirmation
private class SMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent intent) {
switch (getResultCode()) {
case Activity.RESULT_OK:
String phoneNumber = intent.getExtras()
.getString("phonenumber");
alertMessage("Request sent to " + phoneNumber + ".");
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
String phoneNumber1 = intent.getExtras().getString(
"phonenumber");
alertMessage("Sending Failed to " + phoneNumber1 + ".");
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
String phone = intent.getExtras().getString(
"phonenumber");
alertMessage("No service");
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
alertMessage("Null PDU");
Toast.makeText(getBaseContext(), "Null PDU", Toast.LENGTH_SHORT)
.show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
alertMessage("Radio off");
break;
}
}
}
I am searched a lot in Google and SO but none of them solves my issue.
Thanks for your help.