【发布时间】:2013-12-19 16:05:35
【问题描述】:
所以我目前正在开发一个应用程序,该应用程序涉及使用 SMSManager 的标准实例发送文本消息。尽管在连续发送许多消息时似乎存在相对较高的失败率。是否可以检测到失败短信的内容(包括消息正文和收件人)。这就是我目前检测消息是否失败的方式。顺便说一句,sis 对象是另一个类对未发送消息做出反应的回调。
PendingIntent intent;
intent = PendingIntent.getBroadcast(context, 0,
new Intent("SMS_SENT"), 0);
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS sent",
Toast.LENGTH_SHORT).show();
//send callback that a text message was successful
sis.messageSent();
break;
default:
Toast.makeText(getApplicationContext(), "Message unsent", Toast.LENGTH_SHORT);
Bundle unsent = arg1.getExtras();
//send a call back that the message was unsent
//im trying to get the contents of the unsent message and pass it to another activity via a bundle but the pending intent is not returning any values(I checked it with a debugger)
sis.messageFailed();
break;
}
}
}, new IntentFilter("SMS_SENT"));
【问题讨论】:
标签: android text sms broadcastreceiver android-pendingintent