title: SMS DeliveryBroadcast (BroadCastReceiver) OnReceive is never called
body: <p>I was testing some SMS sending and receiving result application. It sends SMS as expected and it toasts "SMS Sent". But it never toasts "SMS delivered". Also it never reaches to</p>
  
  <pre><code>Log.i("BROADCASTRECEIVER", String.valueOf(getResultCode())); 
  </code></pre>
  
  <p>which means OnReceive is never called for SMS_DELIVERED result... Any idea why?...</p>
  
  <pre><code>public class C extends Activity {
  
      static String[] params;
  
      static Context context;
      ProgressDialog pd;
      BroadcastReceiver smsDeliveryBroadcast, smsSendBroadcast;
      String SENT = "SMS_SENT";
      String DELIVERED = "SMS_DELIVERED";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.c);
          params = new String[3];
          params[0] = "00905067161660";
          params[1] = "smsC.";
          params[2] = "smsC..";
          new ServerSMSThread().execute(params);
      }
  
      @Override
      protected void onPause() {
          // TODO Auto-generated method stub
          unregisterReceiver(smsDeliveryBroadcast);
          unregisterReceiver(smsSendBroadcast);
          super.onPause();
      }
  
      @Override
      protected void onResume() {
          // TODO Auto-generated method stub
  
          super.onResume();
      }
  
      public void sendSMS(String phoneNumber, String message) {
          Log.i("NO", phoneNumber);
          PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(
                  SENT), 0);
  
          PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
                  new Intent(DELIVERED), 0);
  
          registerSMS();
  
          SmsManager sms = SmsManager.getDefault();
          sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
  
      }
  
      private void registerSMS() {
          smsSendBroadcast = new BroadcastReceiver() {
              @Override
              public void onReceive(Context context, Intent intent) {
  
  
                  // TODO Auto-generated method stub
                  switch (getResultCode()) {
                  case Activity.RESULT_OK:
                      Toast.makeText(context, "SMS sent", Toast.LENGTH_SHORT)
                              .show();
                      Log.i("MONITOR", "SMS Gonderildi");
                      break;
                  case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                      Toast.makeText(context,
                              "SMS sending failed: Generic failure",
                              Toast.LENGTH_SHORT).show();
                      break;
                  case SmsManager.RESULT_ERROR_NO_SERVICE:
                      Toast.makeText(context, "SMS sending failed: No service",
                              Toast.LENGTH_SHORT).show();
                      Log.i("MONITOR", "SMS sending failed: No service");
                      break;
                  case SmsManager.RESULT_ERROR_NULL_PDU:
                      Toast.makeText(context, "SMS sending failed: Null PDU",
                              Toast.LENGTH_SHORT).show();
                      Log.i("MONITOR", "SMS sending failed: Null PDU");
                      break;
                  case SmsManager.RESULT_ERROR_RADIO_OFF:
                      Toast.makeText(context, "SMS sending failed: Radio off",
                              Toast.LENGTH_SHORT).show();
                      Log.i("MONITOR", "SMS sending failed: Radio off");
                      break;
                  }
              }
          };
          smsDeliveryBroadcast = new BroadcastReceiver() {
              @Override
              public void onReceive(Context context, Intent intent) {
  
                  Log.i("BROADCASTRECEIVER", String.valueOf(getResultCode()));
                  // TODO Auto-generated method stub
                  switch (getResultCode()) {
                  case Activity.RESULT_OK:
                      Toast.makeText(context, "SMS delivered", Toast.LENGTH_SHORT)
                              .show();
                      Log.i("MONITOR", "SMS Teslim edildi");
                      break;
                  case Activity.RESULT_CANCELED:
                      Toast.makeText(context, "SMS not delivered",
                              Toast.LENGTH_SHORT).show();
                      Log.i("MONITOR", "SMS not delivered");
                      break;
  
                  default:
                      Toast.makeText(context, "SMS result bilinmiyor",
                              Toast.LENGTH_SHORT).show();
                      Log.i("MONITOR", "SMS result bilinmiyor");
                      break;
                  }
              }
          };
  
          // ---when the SMS has been sent---
          registerReceiver(smsSendBroadcast, new IntentFilter(SENT));
          // ---when the SMS has been delivered---
          registerReceiver(smsDeliveryBroadcast, new IntentFilter(DELIVERED));
      }
  
  
  
      public class ServerSMSThread extends AsyncTask&lt;String, Void, Void&gt; {
  
          @Override
          protected void onPostExecute(Void result) {
              // TODO Auto-generated method stub
              super.onPostExecute(result);
              if (pd.isShowing())
                  pd.dismiss();
              startActivity(new Intent(C.this,B.class).addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
          }
  
          @Override
          protected void onPreExecute() {
              // TODO Auto-generated method stub
              super.onPreExecute();
              pd = ProgressDialog.show(C.this, "Sending SMS...", "Please wait.");
              Log.i("MONITOR", "SMS Gonderiliyor");
          }
  
          @Override
          protected Void doInBackground(String... params) {
              // TODO Auto-generated method stub
              for (int i = 1; i &lt; params.length; i++) {
                  sendSMS(params[0], params[i]);
              }
              try {
                  Thread.sleep(2000);
              } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              return null;
          }
      }
  
  }
  </code></pre>
  
  <p>AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.tekeli.order"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk android:minSdkVersion="11" /&gt;
      &lt;uses-permission android:name="android.permission.SEND_SMS" &gt;&lt;/uses-permission&gt;
      &lt;application
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name" &gt;
          &lt;activity
              android:name=".ActivityOrderActivity"
              android:label="@string/app_name"&gt;
              &lt;intent-filter &gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name=".B" &gt;&lt;/activity&gt;
           &lt;activity android:name=".C"&gt;&lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>