如何知道Android BroadcastReceiver发送/发送了哪些短信?

如何知道Android BroadcastReceiver发送/发送了哪些短信?,android,sms,broadcastreceiver,smsmanager,Android,Sms,Broadcastreceiver,Smsmanager,我制作了一个简单的应用程序,可以在android上发送多条短信。我找不到发送/传递的短信,因为传递通知没有说明发送/传递的是哪条短信 这是我的代码: this.destination = data[0]; this.body = data[1]; PendingIntent piSend = PendingIntent.getBroadcast(aCtx, 0, new Intent(Cons.SMS_SENT),0); PendingIntent piDeli

我制作了一个简单的应用程序,可以在android上发送多条短信。我找不到发送/传递的短信,因为传递通知没有说明发送/传递的是哪条短信

这是我的代码:

    this.destination = data[0];
    this.body = data[1];

    PendingIntent piSend = PendingIntent.getBroadcast(aCtx, 0, new Intent(Cons.SMS_SENT),0);
    PendingIntent piDelivered = PendingIntent.getBroadcast(aCtx, 0, new Intent(Cons.SMS_DELIVERED), 0);

    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage(destination, null, body, piSend, piDelivered);
然后,我使用广播接收器获取交付状态

public class DeliverSMSBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {

    switch (getResultCode())
    {
        case Activity.RESULT_OK:
            Toast.makeText(context, "SMS delivered",
                    Toast.LENGTH_SHORT).show();
            Log.d(Cons.TAGS+" RK","RESULT_OK=> DELIVER");
            break;
        case Activity.RESULT_CANCELED:
            Toast.makeText(context, "SMS not delivered",
                    Toast.LENGTH_SHORT).show();
            Log.d(Cons.TAGS+" RK","RESULT_CANCELED");
            break;
    }}
}
以下是我的活动:

public class SenderPage extends Activity {
private EditText txtRecepients = null;
private EditText inputSMSText = null;
private Button btnSendSMS = null;

private final BroadcastReceiver outgoingSMSBR = new OutgoingSMSBroadcastReceiver();
private final BroadcastReceiver deliverSMSBR = new DeliverSMSBroadcastReceiver();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.senderpage);
    Log.i(Cons.TAGS, "Sender Page Start");

    this.setTitle("Send Message");

    this.txtRecepients = (EditText) findViewById(R.id.txtRecepients);
    this.inputSMSText = (EditText) findViewById(R.id.inputSMSText);
    this.btnSendSMS = (Button) findViewById(R.id.btnSendSMS);

    txtRecepients.setText("087722079905");      //087722079905 //081214571542

    btnSendSMS.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            //Toast.makeText(SenderPage.this, "Clicked send", Toast.LENGTH_SHORT).show();
            String txtRecepients = SenderPage.this.txtRecepients.getText().toString();
            String inputSMSText = SenderPage.this.inputSMSText.getText().toString();

            new Sender(SenderPage.this,Cons.TAGS).execute(txtRecepients, inputSMSText);
        }
    });

    //txtRecepients.getText().toString();
}

@Override
protected void onResume() {
    registerReceiver(outgoingSMSBR, new IntentFilter(Cons.SMS_SENT));
    registerReceiver(deliverSMSBR, new IntentFilter(Cons.SMS_DELIVERED));
    super.onResume();
}

@Override
protected void onPause() {
    unregisterReceiver(outgoingSMSBR);
    unregisterReceiver(deliverSMSBR);
    super.onPause();
}
}


当我发送了多条短信时,我如何才能获得发送信息以确保发送了哪条短信?

最后,我通过使用SMS create datetime将intent extras添加到待定intent中,然后根据extras数据发送的datetime更新SMS状态,这是一个片段:

Intent sentIntent = new Intent(Cons.SMS_SENT);
sentIntent.putExtra("createdTime", createdTime);

Intent deliveryIntent = new Intent(Cons.SMS_SENT);
deliveryIntent.putExtra("createdTime", createdTime);
然后,我可以在创建的时间内识别发送/传递的短信

 public void onReceive(Context context, Intent intent) {
        String smsDateTimeAsID = intent.getStringExtra("createdTime");
 }

Cons.SMS_发送值和Cons.SMS_发送值

    String SENT = "SMS_SENT";
    String DELIVERED = "SMS_DELIVERED";

嗨,请问您发送的Cons.SMS有什么价值?@Yoesoff。。。嗨,你能保证你的双重广播听众没有任何问题吗?似乎我的代码具有双重广播侦听器,根本不调用。。。。