title: Passing a string from an activity to a broadcast receiver
body: <p>I am having a problem while passing a string from my main activity to my broadcast receiver when the app is not currently open on the screen.</p>
  
  <p>When the MainActivity class is created the intent filter returns the correct information through the broadcast receiver but as soon as the user goes to the homescreen on their phone the broadcast receiver starts returning "null" for the toast when the receiver is triggered offscreen.</p>
  
  <p><strong>1.</strong> New Intent</p>
  
  <pre><code>Intent home_page = new Intent(newIntent.this,MainActivity.class);
  
   ownAddress  = ""+customInput.getText().toString();
    home_page.putExtra("session_number", ""+ownAddress);
  
  startActivity(home_page);
  </code></pre>
  
  <p><br/>
  <strong>2.</strong> MainActivity.java:</p>
  
  <pre><code>public class MainActivity extends DroidGap {
  SmsReceiver mAppReceiver = new SmsReceiver();
  
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      Bundle bundle = getIntent().getExtras();
      final String ownAddress  = bundle.getString("session_number");
  
      registerReceiver(mAppReceiver, new IntentFilter("SmsReceiver"));
       Intent intent = new Intent("SmsReceiver");
        intent.putExtra("passAddress", ownAddress);
      sendBroadcast(intent);
  
   }
  
  }
  </code></pre>
  
  <p><br/>
  <strong>3.</strong> SmsReceiver.java:</p>
  
  <pre><code>public class SmsReceiver extends BroadcastReceiver {
  
   public void onReceive(Context context, Intent intent) {
  
      Toast showme = Toast.makeText(context,"Number: "+intent.getExtras().get("passAddress"),Toast.LENGTH_LONG);
      showme.show();
  
   }
  
  }
  </code></pre>
  
  <p>Is there anyway to pass the string through to the broadcast receiver while the app is only running in the background or regardless of when the MainActivity class is created?</p>