title: Send one SMS to Multiple phone numbers
body: <p>I have an <code>arraylist</code> of <strong>phone numbers</strong>. When I send a message it only sends to the last number on the list. Here is my code.</p>
  
  <pre><code>public void onActivityResult(int requestCode,int resultCode,Intent data){
      super.onActivityResult(requestCode, resultCode, data);
  
      if(requestCode == CONTACT_PICK_REQUEST &amp;&amp; resultCode == RESULT_OK){
  
          ArrayList&lt;Contact&gt; selectedContacts = data.getParcelableArrayListExtra("SelectedContacts");
  
          String display="";
          for(int i=0;i&lt;selectedContacts.size();i++){
              display += (i+1)+"   "+selectedContacts.get(i).toString()+"\n";
              theNumber=selectedContacts.get(i).phone;
          }
          contactsDisplay.setText("Selected Contacts : \n\n"+display);
      }
  }
  
  protected void sendMsg(String theNumber, String myMsg) {
      String SENT = "Message Sent";
      String DELIVERED = "Message Delivered";
  
      PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);
      PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);
  
      registerReceiver(new BroadcastReceiver() {
          public void onReceive(Context arg0, Intent arg1) {
              switch (getResultCode()) {
                  case Activity.RESULT_OK:
  
                          Toast.makeText(MainActivity.this, "SMS SENT", Toast.LENGTH_LONG).show();
                      break;
                  case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                      Toast.makeText(MainActivity.this, "Generic Failure", Toast.LENGTH_LONG).show();
                      break;
                  case SmsManager.RESULT_ERROR_NO_SERVICE:
                      Toast.makeText(MainActivity.this, "No Service", Toast.LENGTH_LONG).show();
                      break;
              }
          }
      }, new IntentFilter(SENT));
  
      registerReceiver(new BroadcastReceiver() {
  
          public void onReceive(Context arg0, Intent arg1) {
              switch (getResultCode()) {
                  case Activity.RESULT_OK:
                      Toast.makeText(getBaseContext(), "SMS delivered", Toast.LENGTH_LONG).show();
                      break;
                  case Activity.RESULT_CANCELED:
                      Toast.makeText(getBaseContext(), "SMS not delivered", Toast.LENGTH_LONG).show();
                      break;
              }
  
          }
      }, new IntentFilter(DELIVERED));
  
      SmsManager sms = SmsManager.getDefault();
      sms.sendTextMessage(theNumber, null, myMsg, sentPI, deliveredPI);
  }
  </code></pre>