title: BroadcastReceiver onReceive is not fired
body: <p>I'm trying to cope with SMS receiving funcions in Android.
  I read a lot of related topics on Stackoverflow and other sites and I tried with a very simple Class that simply print on the console that a message has been received and the message, but I cannot figure out why it doesn't work.</p>
  
  <p>I see that similar questions remained unanswered in the past (see <a href="https://stackoverflow.com/questions/6966902/android-broadcast-receiver-not-being-fired">Android - Broadcast Receiver not being fired</a>)</p>
  
  <p>Hope someone could find where's the problem with my code.</p>
  
  <p>Code:</p>
  
  <pre><code>package com.storassa.android.smsapp;
  
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.telephony.SmsMessage;
  
  public class SmsReceiver extends BroadcastReceiver {
  
  private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
  private static final String TAG = "SMSBroadcastReceiver";
  
  @Override
  public void onReceive(Context context, Intent intent) {
  System.out.println("Intent recieved: " + intent.getAction());
  
  if (intent.getAction().equals(SMS_RECEIVED)) {
  Bundle bundle = intent.getExtras();
  if (bundle != null) {
  Object[] pdus = (Object[])bundle.get("pdus");
  final SmsMessage[] messages = new SmsMessage[pdus.length];
  for (int i = 0; i &lt; pdus.length; i++) {
  messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
  }
  if (messages.length &gt; -1) {
  System.out.println("Message recieved: " + messages[0].getMessageBody());
          }
      }
  }
       }
  }
  </code></pre>
  
  <p>And Manifest</p>
  
  <pre><code>&lt;manifest package="com.storassa.android.smsapp"
      android:versionCode="1"
      android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;uses-sdk android:minSdkVersion="6" android:targetSdkVersion="6"/&gt;
      &lt;uses-permission android:name="android.permission.RECEIVE_SMS"&gt;&lt;/uses-permission&gt;
  
      &lt;application android:label="@string/app_name" android:permission="android.permission.RECEIVE_SMS"&gt;
          &lt;receiver android:name="com.storassa.android.smsapp.SmsReceiver"
              android:enabled="true"
              android:exported="true"&gt;
              &lt;intent-filter android:priority="999"&gt;
                  &lt;action android:name="android.provider.Telephony.SMS_RECEIVED"&gt;&lt;/action&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
  
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>