Collect data in sending SMS?

I want to send an sms message. If the text is too long, I divided it into several posts. I am trying to add additional information to the "sent" intention to find out which part was sent, and when all the parts are completed:

ArrayList<String> messageParts = ...; for (int i = 0; i < messageParts.size(); i++) { sms.sendTextMessage( address, null, messageParts.get(i), generateIntent(context, messageParts.size(), i), null)); } PendingIntent generateIntent(Context context, int partCount, int partIndex) { Intent intent = new Intent("SMS_SENT"); intent.putExtra("partCount", partCount); intent.putExtra("partIndex", partIndex); return PendingIntent.getBroadcast(context, 0, intent, 0); } 

The message is sent, and I will catch the intention when sending each part, but it always has the same data. For example, "partIndex" is always zero, although it must be one for the second message. It seems that the same intention rushes all the time at my broadcast receiver. What is the right way to do this?

thank

+3
android
Dec 30 '09 at 20:58
source share
2 answers

Try using FLAG_ONE_SHOT or otherwise PendingIntent previous PendingIntent before trying to create a new one.

+8
Dec 30 '09 at 10:17
source share

You need to add a unique request code to your broadcast (the second argument to the getBroadcast method) in order to send unique values. For more information, see this other question: Differentiation of delivery reports of two separate SMS messages

0
Sep 20 '13 at 18:37
source share



All Articles