title: Pending Intents for sending SMS not working well while sending many messages
body: <p>I am Developing an App , In which I send SMS and I need to find if It's delivered or not.
  Every thing seems to be well if I send A message to a person.</p>
  
  <p>But In some situations I got wrong Information , for example , First I send A message to number 0000 (But It will not deliver) and after it I send a message to number 0001 and It delivers (message to 0000 is still not delivered) but I got a toast with : sms delivered to 0000(But only message to 0001 is delivered) , What Should I do to fix this conflict in Delivery reports ?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>try {
      SmsManager smsManager = SmsManager.getDefault();
  
      String to = "5556";
      String body = "Test Message";
  
      String SENT = "SMS_SENT";
      String DELIVERED = "SMS_DELIVERED";
  
      PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);
      PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED).putExtra("senderNumber", to), 0);
  
      registerReceiver(new BroadcastReceiver() {
          @Override
          public void onReceive(Context arg0, Intent arg1) {
              switch (getResultCode()) {
                  case Activity.RESULT_OK:
                      Toast.makeText(arg0, "SMS sent", Toast.LENGTH_LONG).show();
                      break;
                  default:
                      Toast.makeText(arg0, "Error", Toast.LENGTH_LONG).show();
                      break;
              }
          }
      }, new IntentFilter(SENT));
  
      registerReceiver(new BroadcastReceiver() {
          @Override
          public void onReceive(Context arg0, Intent arg1) {
              switch (getResultCode()) {
                  case Activity.RESULT_OK:
                      String s = arg1.getStringExtra("senderNumber");
                      Toast.makeText(getBaseContext(), "SMS delivered to " + s, Toast.LENGTH_LONG).show();
                      break;
                  default:
                      Toast.makeText(getBaseContext(), "SMS not delivered", Toast.LENGTH_LONG).show();
                      break;                        
              }
          }
      }, new IntentFilter(DELIVERED));        
  
      smsManager.sendTextMessage(to.getText().toString(), null, body.getText().toString(), sentPI, deliveredPI);
  }
  catch (Exception ex) {
      Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
  }
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>I find that If I add a unique id to Intent action (DELIVERED+id) It will be fine and no conflict.
  but I don't register the Receiver on creating message , I use manifest file to do this:</p>
  
  <pre><code>&lt;receiver android:name=".SendBroadcastReceiver" &gt;
      &lt;intent-filter&gt;
          &lt;action android:name="com.example.myapp.SMS_SENT" /&gt;
          &lt;action android:name="com.example.myapp.SMS_DELIVERED" /&gt;
      &lt;/intent-filter&gt;
  &lt;/receiver&gt; 
  </code></pre>
  
  <p>And also a Receiver class named SendBroadcastReceiver to handle sms delivery.</p>
  
  <p>If I add a unique id to action , how can I add them in manifest file?</p>