title: BroadcastReceiver not working after BOOT_COMPLETED
body: <p>I'm trying to intercept incoming SMS right after boot_completed but i'm having a problem with a NullPointerException in this line:</p>
  
  <pre><code>Object[] rawMsgs=(Object[])intent.getExtras().get("pdus");
  </code></pre>
  
  <p>Here's my manifest:
      
      
          </p>
  
  <pre><code>    &lt;uses-permission android:name="android.permission.SEND_SMS"&gt;&lt;/uses-permission&gt; 
      &lt;uses-permission android:name="android.permission.RECEIVE_SMS"&gt;&lt;/uses-permission&gt; 
      &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"&gt;&lt;/uses-    permission&gt;
      &lt;uses-permission android:name="android.permission.INTERNET"&gt;&lt;/uses-permission&gt;
      &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"&gt;&lt;/uses-permission&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
  
      &lt;application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar"&gt;
          &lt;receiver android:name=".SMSReceiver" 
              android:permission="android.permission.BROADCAST_SMS"
              &gt; 
              &lt;intent-filter android:priority="1000"&gt; 
                  &lt;action     android:name="android.provider.Telephony.SMS_RECEIVED"&gt;&lt;/action&gt;
                  &lt;action android:name="android.intent.action.BOOT_COMPLETED"&gt;&lt;/action&gt;
              &lt;/intent-filter&gt; 
          &lt;/receiver&gt;
      &lt;/application&gt;
  </code></pre>
  
  <p>Receiver:</p>
  
  <pre><code>public class SMSReceiver extends BroadcastReceiver 
      { 
  
  
      private final LocationListener locationListener = new LocationListener() {
            public void onLocationChanged(Location location) {
  
  
            }
  
            public void onProviderDisabled(String provider){}
            public void onProviderEnabled(String provider) {}
            public void onStatusChanged(String provider, int status, Bundle extras) {} 
          };
  
      @Override
      public void onReceive(Context context, Intent intent) {
  
  
          LocationManager lm = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE); 
          //Get as fine grained location as possible, while saving battery life.
          Criteria criteria = new Criteria();
          criteria.setAccuracy(Criteria.ACCURACY_FINE);
          criteria.setAltitudeRequired(false);
          criteria.setBearingRequired(false);
          criteria.setCostAllowed(true);
          criteria.setPowerRequirement(Criteria.POWER_LOW);
          String provider = lm.getBestProvider(criteria, true);
          Toast toast3 = Toast.makeText(context, "Provider: "+provider, Toast.LENGTH_LONG);
          toast3.show();
  
          Object[] rawMsgs=(Object[])intent.getExtras().get("pdus");
  
          for (Object raw : rawMsgs) {
              SmsMessage msg=SmsMessage.createFromPdu((byte[])raw);
              SmsManager sms = SmsManager.getDefault();
              if (msg.getMessageBody().toUpperCase().contains("LOC")) {
                  Log.w("SMS:"+msg.getOriginatingAddress(),
                              msg.getMessageBody());
                  Toast toast1 = Toast.makeText(context, "Phone Number: "+msg.getOriginatingAddress()+" Message: "+msg.getMessageBody(), Toast.LENGTH_LONG);
                  toast1.show();
                  abortBroadcast();
  
                  if(provider!=null){
  
  
                      lm.requestLocationUpdates(provider, 0, 0, locationListener);
  
                      if(lm != null)
                      {
  
                          Location last_good = lm.getLastKnownLocation(provider);
                          if(last_good != null)
                          {
                              Toast.makeText(context, "Got Message from " + msg.getOriginatingAddress() + " , Sending" + last_good.toString(),     Toast.LENGTH_SHORT).show();
                              //sendSMS(msg.getOriginatingAddress(), "http://maps.google.com?q=" + last_good.convert(last_good.getLatitude(), Location.FORMAT_DEGREES) + "," + last_good.convert(last_good.getLongitude(), Location.FORMAT_DEGREES), context);
  
                              //sendSMS(msg.getOriginatingAddress(), last_good.getLatitude() + "," + last_good.getLongitude(), context);
                              sms.sendTextMessage(msg.getOriginatingAddress(), null, last_good.getLatitude() + "," + last_good.getLongitude(), null, null); 
                              lm.removeUpdates(locationListener);
                          }
                          else
                          {
                              lm.removeUpdates(locationListener);
                                  sendSMS(msg.getOriginatingAddress(),"Location Not Available. Possible Reasons: Phone is Off, GPS is Off, No Satellites in sight", context);
  
                          }
                      }
  
                  }
                  else{
                      sendSMS(msg.getOriginatingAddress(),"Location Not Available. Possible Reasons: Phone is Off, GPS is Off, No Satellites in sight", context);
  
                  }
  
  
  
              }
          }
       }
  </code></pre>
  
  <p>Thanks.</p>