在我的应用我在一个时间,这工作完全正常发送多个短信。 但是,当我试图接收广播接收机确认消息我期待着得到所有的数字,但我在正数的接收相同的一个号码,而不是结束。
发送短信
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);
接收发送确认
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;
}
}
}
我搜索了很多在谷歌和SO但没有人解决了我的问题。
谢谢你的帮助。