我正在发送 2 条短信,我想要 2 条 toast 消息
1)“已发送短信 - 第一个号码”和
2)“已发送短信-第二个号码”
但是,我收到 2 条 Toast 消息都显示消息
1),消息发生了什么
2)? 少了什么东西?
谢谢。
registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode())
{
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS sent - " + arg1.getStringExtra("SendTo"),
Toast.LENGTH_LONG).show();
break;
}
}
}, new IntentFilter(SENT));
SmsManager sms = SmsManager.getDefault();
Intent intent = new Intent(SENT);
intent.putExtra("SendTo", "first number");
PendingIntent sentIntents = PendingIntent.getBroadcast(this, 0, intent, 0);
sms.sendTextMessage("1234", null, message, sentIntents, null);
Intent intent1 = new Intent(SENT);
intent1.putExtra("SendTo", "second number");
PendingIntent sentIntents1 = PendingIntent.getBroadcast(this, 0, intent1, 0);
sms.sendTextMessage("456", null, message, sentIntents1, null);