SendMultipartTextMessage and track sending and receiving

I read several threads on how to send and receive multi-page messages. I implemented the following code and it works!

      PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);
      PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);
        //---when the SMS has been sent---
        registerReceiver(SMSBroadcastReceiver1, new IntentFilter(SENT));
        //---when the SMS has been delivered---
        registerReceiver(SMSBroadcastReceiver2, new IntentFilter(DELIVERED));    


    SmsManager smsManager = SmsManager.getDefault();
    ArrayList<String> parts = smsManager.divideMessage(smsToSend);

    ArrayList<PendingIntent> sentList = new ArrayList<PendingIntent>();
    ArrayList<PendingIntent> deliveredList = new ArrayList<PendingIntent>();
    for (int i = 0; i < parts.size(); i++) {
        sentList.add(sentPI);
        deliveredList.add(deliveredPI);
    }


    //smsManager.sendTextMessage(phoneNumber, null, smsToSend, sentPI, deliveredPI);
    smsManager.sendMultipartTextMessage(phoneNumber, null, parts, sentList, deliveredList);

and I have one registered SMSBroadcastReceiver2 and SMSBroadcastReceiver1.

I am worried about the following:

I have one single PendingIntentsentPi and deliveredPithat are registered with SMSBroadcastReceiver1and SMSBroadcastReceiver2.

And then I put them in an ArrayList several times, depending on how long this message is.

It's good? Or should I have different intentions and receivers for each part of the message.

, ? , , , , ( , Toast ), . ...?

+5

All Articles