如何让Android的循环发送每条短信的发送报告?

问题描述:

我工作的短信应用。我需要在循环发送短信。注册广播接收器中发送和接收状态。但问题是,如何区分哪个Delievery通知是为我发短信哪。我使用SMSMANAGER类来发送短信。我的问题是类似的这里讨论:如何监控每一个短信发送状态?

I am working on SMS app. I need to send SMS in loop. Registered Broadcast Receiver for SENT and DELIVERED status. But problem is how to distinguish which Delievery notification is for which SMS that i sent. I am using SMSMANAGER class to send SMS. My problem is similar discussed here: How to monitor each of Sent SMS status?

要SMS可以使用意图额外的字段进行区分。

To distinguish between SMS you can use extra field of the intent.

像::

Intent sent = new Intent(SENT);
intent.putExtra("MessageNum", i);
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0,
    sent, 0);

Intent delivered = new Intent(DELIVERED);
intent.putExtra("MessageNum", i);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
    delivered, 0);

而在广播接收器接收这些意图,使用 intent.getIntExtra()来知道邮件数量。