3

我尝试发送群组短信,它工作正常。但是,我想知道在发送状态下收到了哪些号码:

为了了解交付状态,我使用了以下代码:

public class SMSdelivered extends BroadcastReceiver {

        @Override
        public void onReceive(Context context, Intent intent) {
            // TODO Auto-generated method stub

            switch (getResultCode()) {
            case Activity.RESULT_OK:
                Toast.makeText(context, "SMS DELIVERED", Toast.LENGTH_SHORT).show();
               //want to display mobile number tooo
                break;
            case Activity.RESULT_CANCELED:
                Toast.makeText(context, "SMS NoT DELIVERED", Toast.LENGTH_SHORT)
                        .show();
                break;
            }

        }

    }

目前SMS DELIVERED消息显示正常。但是,这里我想显示已交付目标的手机号码。如何使用广播接收器获取传递的目标手机号码?

任何想法??

提前致谢..

4

1 回答 1

6

您可以在Intent用于创建PendingIntent带有收件人号码的 Delivered 的附件上附加一个额外的内容,然后在您的BroadcastReceiver.

Intent delivered = new Intent(ACTION_SMS_DELIVERED);
delivered.putExtra("addressee", number);
PendingIntent pendingDelivered = PendingIntent.getBroadcast(context, 0, delivered, 0);

onReceive()

String number = intent.getStringExtra("addressee");
于 2014-04-21T08:06:37.877 回答