How can i create an Outbox capable of sending multiple SMS to same recipient?
<p>I am in the middle of creating an App that will send multiple SMS messages to a single recipient - one every minute. These messages contain GPS coordinates as part of a tracking system that is attached to an object. </p>

<p>The object will be moving in and out of signal so messages may or may not be sent. I would like to store these messages and send them at a later date. This means I need to send a lot of SMS messages when the object is next in signal. HOWEVER. I run into trouble when I try to send the stored messages. Is there any way to identify what SMS message belongs to what BroadcastReceiver? Knowing this would allow me to save (for sending later) any message that was not sent and at the same time remove any messages that have already been sent.</p>

<p>IE the object travels out of signal. Every minute a GPS coordinate is retrieved. Message is not sent so it is stored in a vector. after 5 minutes object is back in signal with 5 messages to send. If halfway during the sending of these 5 messages the object loses signal I would and is only able to send 3 of the messages (no particular order) I would like to know which 3 were sent and which 2 were not.</p>

<p>Some code is below.</p>

<pre><code>public class FixingmsgsActivity extends Activity {

private static final int MAX_SMS_MESSAGE_LENGTH = 160;                
private static final String SMS_DELIVERED = "SMS_DELIVERED";          
private static final String SMS_SENT = "SMS_SENT";

private String SendTo = "02102980174";
private String SendToFull = "+642102980174";

private Vector&lt;String&gt; testmsg = new Vector&lt;String&gt;();




/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    registerReceiver(sendreceiver, new IntentFilter(SMS_SENT));          
    registerReceiver(deliveredreceiver, new IntentFilter(SMS_DELIVERED));
//  registerReceiver(smsreceiver, new IntentFilter("android.provider.Telephony.SMS_RECEIVED")); 

    testmsg.addElement("one");
    testmsg.addElement("two");
    testmsg.addElement("three");
    testmsg.addElement("four");
    testmsg.addElement("five");
    testmsg.addElement("six");
    testmsg.addElement("seven");
    testmsg.addElement("eight");
    testmsg.addElement("nine");


    for(int i=0;i &lt; testmsg.size();i++){
        sendSms(SendTo,testmsg.elementAt(i));
    }
 }


private void sendSms(String phonenumber,String message){                    
    SmsManager manager = SmsManager.getDefault();                    
    Intent sendIntent = new Intent("SMS_SENT"); 
    sendIntent.putExtra("message", message);        
   PendingIntent piSend = PendingIntent.getBroadcast(this, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); 
   PendingIntent piDelivered = PendingIntent.getBroadcast(this, 0, new Intent(SMS_DELIVERED), 0);

   int length = message.length();                                    
            if(length &gt; MAX_SMS_MESSAGE_LENGTH)                  
            {                          
                ArrayList&lt;String&gt; messagelist = manager.divideMessage(message);                               
                manager.sendMultipartTextMessage(phonenumber, null, messagelist, null, null);                  
            }                  
            else                  
            {               
                //Toast.makeText(getBaseContext(), message, Toast.LENGTH_SHORT).show();
                manager.sendTextMessage(phonenumber, null, message, piSend, piDelivered);
            }          
}      

private BroadcastReceiver sendreceiver = new BroadcastReceiver()          
{                  

    @Override                  
    public void onReceive(Context context, Intent intent)                  
    {

    switch(getResultCode())                          
    {                                  
        case Activity.RESULT_OK:  //Message has been sent
        break;

        case SmsManager.RESULT_ERROR_GENERIC_FAILURE: //message not sent. Which one? I would like to store this SMS so I can send it later.
        break;

        case SmsManager.RESULT_ERROR_NO_SERVICE:  //message not sent. Which one?
        break;

        case SmsManager.RESULT_ERROR_NULL_PDU:   //message not sent. Which one?
        break; 

        case SmsManager.RESULT_ERROR_RADIO_OFF: //message not sent. Which one?
        break;                          
    }                                                    

    }          
    };       

    private BroadcastReceiver deliveredreceiver = new BroadcastReceiver()

    {                  
        @Override                  
        public void onReceive(Context context, Intent intent)                  
        {                          
            String info = "Delivery information: ";                                                    
            switch(getResultCode())                          
            {                                  
            case Activity.RESULT_OK: info += "delivered"; 
            break;                                  
            case Activity.RESULT_CANCELED: info += "not delivered"; 
            break;                          
            }                                                                  
        }          
    };                
  }
</code></pre>

<p>I have tried using Intents with putExtra however this will only give the last SMS extra in the broadcastreceiver. For example in the above code the extra "message" in the onrecieve method would output "nine" "nine" "nine" "nine" "nine" "nine" "nine" "nine" "nine" </p>

<p>As I am sending multiple messages I would like that to be something like</p>

<p>"one" "two" etc. This wiould allow me to identify what message was not sent and what one was</p>

<p>Sorry for the long read. Thanks
Daniel H</p>
