Pergunta

I tried to send group sms and it works fine. But, I want to know which numbers are received my sms on delivered status:

For know delivered status I used below code:

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;
            }

        }

    }

Currently SMS DELIVERED message displayed fine. But, here I want to display mobile number of delivered target. How can I get delivered target mobile number using broadcast receiver??

Any idea??

Thanks in advance..

Foi útil?

Solução

You could attach an extra to the Intent used to create the Delivered PendingIntent with the addressee's number, then retrieve it in your BroadcastReceiver.

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

In onReceive():

String number = intent.getStringExtra("addressee");
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top