title: Broadcast Receiver with sendMultiPartTextMessage
body: <p>I've been trying to get the status result code from sendMultipartTextMessage, the thing i don't understand is if the broadcast receiver works with sendTextMessage, why doesnt it work with sendMultipartTextMessage? I've searched far and wide and looked and code examples but just cant see any obvious reasons as to why this wont work. Can anyone shed any light on this?</p>
  
  <pre><code>ArrayList&lt;String&gt; messages = sms.divideMessage(text);
  int messageCount = messages.size();
  ArrayList&lt;PendingIntent&gt; deliveryIntents = new ArrayList&lt;PendingIntent&gt;(messageCount);
  ArrayList&lt;PendingIntent&gt; sentIntents = new ArrayList&lt;PendingIntent&gt;(messageCount);
  
  for (int j = 0; j &lt; messageCount; j++) {
      sentIntents.add(
              PendingIntent.getBroadcast(context, 0, new Intent(SENT_ACTION),
              0));
  }
  sms.sendMultipartTextMessage(phoneNumber, null, messages, sentIntents, null);
  </code></pre>
  
  <p>Here's my <code>BroadcastReceiver</code>:</p>
  
  <pre><code>private BroadcastReceiver messageSentReceiver = new BroadcastReceiver() {      
      @Override
      public void onReceive(Context context, Intent intent) {
          switch (getResultCode()) {
             case Activity.RESULT_OK:
                 Toast.makeText(context, "SMS sent", Toast.LENGTH_SHORT).show();
                 break;
             case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                Toast.makeText(context, "Generic failure", Toast.LENGTH_SHORT).show();
                break;
            case SmsManager.RESULT_ERROR_NO_SERVICE:
                Toast.makeText(context, "No service", Toast.LENGTH_SHORT).show();
                break;
            case SmsManager.RESULT_ERROR_NULL_PDU:
                Toast.makeText(context, "Null PDU", Toast.LENGTH_SHORT).show();
                break;
            case SmsManager.RESULT_ERROR_RADIO_OFF:
                Toast.makeText(context, "Radio off", Toast.LENGTH_SHORT).show();
                break;
            }
        }
   };
  </code></pre>
  
  <p>The code is done as below: </p>
  
  <pre><code>sentIntents = new ArrayList&lt;PendingIntent&gt;();
  sentIntent = PendingIntent.getBroadcast(context, 0, new Intent(SENT_ACTION), 0);
  deliveredIntent = PendingIntent.getBroadcast(context, 0, new Intent(DELIVERED_ACTION), 0);
  
  context.registerReceiver(messageSentReceiver, new IntentFilter(SENT_ACTION));
  context.registerReceiver(messageDeliveredReceiver, new IntentFilter(DELIVERED_ACTION));
  </code></pre>
  
  <p>If anyone could shed any light on this, i would really appreciate it. I just can't see why this could work with <code>sendTextMessage</code> but not on <code>sendMultipartTextMessage</code>. </p>
  
  <p>Thanks.</p>