在我的应用程序我在一次工作这完全正常发送多个短信。但是,当我试图接收广播接收器确认消息我期待得到所有的数字,但我在n个数接受同样的一个号码,而不是结束。
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.
要发送短信
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但他们没有解决我的问题。
I am searched a lot in Google and SO but none of them solves my issue.
感谢您的帮助。
尝试意向之前的所有时间,具有唯一的ID为集挂起意图
Try to Pending intent with all time with Unique id for Set Pending intent
的PendingIntent的PendingIntent = PendingIntent.getService(这一点,UID,mIntent,PendingIntent.FLAG_ONE_SHOT);
PendingIntent pendingintent = PendingIntent.getService(this, uId, mIntent, PendingIntent.FLAG_ONE_SHOT);
上一篇:如何获得数行一个TextView在Android的显示如何获得、TextView、Android
下一篇:通过使用actionbarsherlock创建Android的底栏actionbarsherlock、Android