title: Android crash after using a broadcast on a secondary activity
body: <p>My aplication has a Log activity where the user enters a cellphone number. He can send a code "1234020" with the button ("ENVIAR") to that number and change a TextView with the content and the number of an incoming message.</p>
  
  <p>With the button "SIGUIENTE" the application must to go to the second activity <code>LucesAlarma</code>. There, they modify a <code>TextView</code> with the telephone number of the first activity and send (With the button "ENVIARLA") and receive messages.</p>
  
  <p>The button "Atras" should return to the first activity. The problem is that the application crashes after pushing the button "Siguiente" in <code>MainActivity</code>. I believe there is a problem in the Manifest.</p>
  
  <p>Main Activity:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
      Button ENVIAR,SIGUIENTE;
      EditText NUMEROT;
      TextView CONTENIDO;
      IntentFilter intentFilter;
  
      private BroadcastReceiver intentReciever = new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
  
              String MENSAJE = intent.getExtras().getString("mensaje");
              String NUMERODELMENSAJE  = intent.getExtras().getString("numero");
              CONTENIDO=(TextView)findViewById(R.id.tvSMScontenido);
              CONTENIDO.setText(MENSAJE+NUMERODELMENSAJE);
          }
      };
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          intentFilter = new IntentFilter();
          intentFilter.addAction("SMS_RECEIVED_ACTION");
  
          ENVIAR     = (Button) findViewById(R.id.bEnviarMA);
          SIGUIENTE  = (Button)findViewById(R.id.bSiguienteMA);
          NUMEROT    = (EditText)findViewById(R.id.etNumeroTelf);
          ENVIAR.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  String ELMENSAJE = "1234020";
                  String ELNUMERO = NUMEROT.getText().toString();
                  EnviarSMS(ELMENSAJE, ELNUMERO);
                  Toast.makeText(getApplicationContext(), "Ya esta ya", Toast.LENGTH_LONG).show();
              }
          });
  
          SIGUIENTE.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent intento = new Intent(MainActivity.this, LucesAlarma.class);
                  intento.putExtra("numero", NUMEROT.getText().toString());
                  startActivity(intento);
              }
          });
      }
  
      @Override
      protected void onResume() {
          registerReceiver(intentReciever, intentFilter);
          super.onResume();
      }
  
      @Override
      protected void onPause() {
          unregisterReceiver(intentReciever);
          super.onPause();
      }
  
      protected void EnviarSMS(String elmensaje, String elnumero) {
  
          SmsManager SMS = SmsManager.getDefault();
          SMS.sendTextMessage(elnumero, null, elmensaje, null, null);
      }
  }
  </code></pre>
  
  <p>Second Activity (LucesAlarma)</p>
  
  <pre><code>public class LucesAlarma extends AppCompatActivity {
      TextView NUMEROLA,MENSAJELA;
      Button ENVIARLA,ATRAS;
      IntentFilter intentFilterLA;
  
      private BroadcastReceiver intentRecieverLA = new BroadcastReceiver(){
          @Override
          public void onReceive(Context context, Intent intent){
  
              String MENSAJE = intent.getExtras().getString("mensaje");
              String NUMERODELMENSAJE  = intent.getExtras().getString("numero");
              MENSAJELA=(TextView)findViewById(R.id.tvMensajeLA);
              MENSAJELA.setText(MENSAJE+NUMERODELMENSAJE);
          }
      };
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_luces_alarma);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
          Intent intent = getIntent();
          final String numeropos =intent.getStringExtra("numero");
          NUMEROLA=(TextView)findViewById(R.id.tvNumeroLA);
          NUMEROLA.setText(numeropos);
  
          ENVIARLA=(Button)findViewById(R.id.bEnviarLA);
          ENVIARLA.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  String ELMENSAJE = "1234020";
                  String ELNUMERO = numeropos;
                  EnviarSMS(ELMENSAJE, ELNUMERO);
                  Toast.makeText(getApplicationContext(), "Enviado", Toast.LENGTH_LONG).show();
              }
          });
  
          ATRAS=(Button)findViewById(R.id.bAtras);
          ATRAS.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent intentoLA = new Intent(LucesAlarma.this, MainActivity.class);
                  startActivity(intentoLA);
              }
          });
  
      }
  
      @Override
      protected void onResume() {
          registerReceiver(intentRecieverLA,intentFilterLA);
          super.onResume();
      }
  
      @Override
      protected void onPause() {
          unregisterReceiver(intentRecieverLA);
          super.onPause();
      }
  
      protected void EnviarSMS(String elmensaje, String elnumero) {
  
          SmsManager SMS = SmsManager.getDefault();
          SMS.sendTextMessage(elnumero, null, elmensaje, null, null);
      }
  }
  </code></pre>
  
  <p>SMS Reciver java class:</p>
  
  <pre><code>public class ReceptorSMS extends BroadcastReceiver {
      @Override
      public void onReceive(Context context, Intent intent) {
          Bundle bundle = intent.getExtras();
          SmsMessage[]messages=null;
          String str = "";
          String num = "";
          String men = "";
          if(bundle != null) {
              Object[] pdus = (Object[]) bundle.get("pdus");
              assert pdus != null;
              messages = new SmsMessage[pdus.length];
              for (int i=0 ; i&lt;messages.length;i++) {
                  messages[i]=SmsMessage.createFromPdu((byte[])pdus[i]);
                  num = messages[i].getDisplayOriginatingAddress();
                  str += "Mensaje de" +messages[i].getOriginatingAddress();
                  str += ":";
                  str += messages[i].getMessageBody();
                  str += "\n";
                  men = messages[i].getMessageBody();
              }
              //           Toast.makeText(context,str,Toast.LENGTH_SHORT).show();
              Intent broadcastIntent = new Intent();
              broadcastIntent.setAction("SMS_RECEIVED_ACTION");
              broadcastIntent.putExtra("sms", str);
              broadcastIntent.putExtra("mensaje", men);
              broadcastIntent.putExtra("numero", num);
              context.sendBroadcast(broadcastIntent);
          }
      }
  }
  </code></pre>
  
  <p>And the manifest, I can't identify the problem :'v</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.example.josue.smartwasip"&gt;
  
      &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;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name"
              android:theme="@style/AppTheme.NoActionBar"&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=".LucesAlarma"
              android:label="@string/title_activity_luces_alarma"
              android:theme="@style/AppTheme.NoActionBar"&gt;
  
              &lt;intent-filter&gt;
                  &lt;action android:name="com.example.josue.smartwasi" /&gt;
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;/intent-filter&gt;
  
          &lt;/activity&gt;
          &lt;receiver android:name=".ReceptorSMS"&gt;
              &lt;intent-filter&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>Here is the exption:</p>
  
  <pre><code>03-08 15:39:15.059 1385-1385/com.example.josue.smartwasip E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.josue.smartwasip, PID: 1385
      java.lang.RuntimeException: Unable to resume activity {com.example.josue.smartwasip/com.example.josue.smartwasip.LucesAlarma}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.IntentFilter.writeToParcel(android.os.Parcel, int)' on a null object reference
          at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103)
          at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
          at android.app.ActivityThread.-wrap11(ActivityThread.java)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
          at android.os.Handler.dispatchMessage(Handler.java:102)
          at android.os.Looper.loop(Looper.java:148)
          at android.app.ActivityThread.main(ActivityThread.java:5417)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
       Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.IntentFilter.writeToParcel(android.os.Parcel, int)' on a null object reference
          at android.app.ActivityManagerProxy.registerReceiver(ActivityManagerNative.java:3008)
          at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1184)
          at android.app.ContextImpl.registerReceiver(ContextImpl.java:1152)
          at android.app.ContextImpl.registerReceiver(ContextImpl.java:1146)
          at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:554)
          at com.example.josue.smartwasip.LucesAlarma.onResume(LucesAlarma.java:76)
          at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1258)
          at android.app.Activity.performResume(Activity.java:6312)
          at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3092)
          at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134) 
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481) 
          at android.app.ActivityThread.-wrap11(ActivityThread.java) 
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
          at android.os.Handler.dispatchMessage(Handler.java:102) 
          at android.os.Looper.loop(Looper.java:148) 
          at android.app.ActivityThread.main(ActivityThread.java:5417) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  </code></pre>