title: How to pass data to BroadcastReceiver?
body: <p>What I am trying to do is that the numbers to which my application sends messages to, are passed to the BraodcastReceiver...but so far either I am getting null or BroadcastReceiver just simply crashes..</p>
  
  <p>here is my intent for BroadcastReceiver from CreateMessage class...</p>
  
  <pre><code>        Intent intent = new Intent();
          Bundle bundle = new Bundle();
          bundle.putString("phN", phoneNo);
          intent.putExtras(bundle);
          startActivity(intent);
  </code></pre>
  
  <p>And in BroadcastReceiver (SmsReceiver class) I am trying to catch intent like this..</p>
  
  <pre><code>public void onReceive(Context context, Intent intent) {
      //---get the SMS message passed in---
      Bundle bundle = intent.getExtras();
      try{
      //receiveNumbers = intent.getExtras().get("phN").toString();
          String  receiveNumbers = intent.getStringExtra("phN");
          Toast.makeText(context, receiveNumbers, Toast.LENGTH_LONG).show();
      }catch(Exception e){
          e.printStackTrace();
      }
  </code></pre>
  
  <p>My Manifest File:</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.AEM_n"
        android:versionCode="2" android:versionName="2.0"&gt;
      &lt;uses-sdk android:minSdkVersion="8" /&gt;
      &lt;uses-permission android:name="android.permission.READ_CONTACTS"/&gt;
      &lt;uses-permission android:name="android.permission.READ_SMS"/&gt;    
      &lt;uses-permission  android:name="android.permission.SEND_SMS"/&gt;
      &lt;uses-permission  android:name="android.permission.RECEIVE_SMS"/&gt;
  
      &lt;application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"&gt;
          &lt;activity android:name=".new_menu"
                    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:label="@string/app_name"
              android:name=".SetEvent" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.AEM_n.SETEVENT" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
              &lt;/activity&gt;
              &lt;activity
              android:label="@string/app_name"
              android:name=".AddParticipants" /&gt;
              &lt;activity
              android:label="@string/app_name"
              android:name=".CreateMessage" /&gt;
              &lt;activity
              android:label="@string/app_name"
              android:name=".DataBaseClass" /&gt;
              &lt;activity 
              android:label="@string/app_name"
              android:name=".IntentReceiver"/&gt;
              &lt;activity 
              android:label="@string/app_name"
              android:name=".SmsReceiver"
              /&gt;
              &lt;receiver android:name=".SmsReceiver" android:exported="true"&gt;
              &lt;intent-filter android:priority="999"&gt;
              &lt;action android:name="android.provider.Telephony.SMS_RECEIVED"/&gt;
              &lt;/intent-filter&gt;
              &lt;/receiver&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>I have already tried all the answers given Stackoverflow...But no use...</p>
  
  <p>Please guys tell me where I am going wrong...Thanks!</p>
  
  <p>Error Log: </p>
  
  <pre><code>04-07 02:34:02.770: ERROR/AndroidRuntime(25593): FATAL EXCEPTION: main
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593): java.lang.RuntimeException: Error receiving broadcast Intent { act=com.myapp.myaction (has extras) } in com.AEM_n.SmsReceiver@405a07c8
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593):     at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:722)
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593):     at android.os.Handler.handleCallback(Handler.java:587)
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593):     at android.os.Handler.dispatchMessage(Handler.java:92)
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593):     at android.os.Looper.loop(Looper.java:123)
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593):     at android.app.ActivityThread.main(ActivityThread.java:3701)
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593):     at java.lang.reflect.Method.invokeNative(Native Method)
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593):     at java.lang.reflect.Method.invoke(Method.java:507)
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593):     at dalvik.system.NativeStart.main(Native Method)
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593): Caused by: java.lang.NullPointerException
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593):     at com.AEM_n.SmsReceiver.onReceive(SmsReceiver.java:37)
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593):     at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:709)
  04-07 02:34:02.770: ERROR/AndroidRuntime(25593):     ... 9 more
  </code></pre>