title: Android keep BroadcastReceiver in background
body: <p>I created a BroadcastReceiver and it runs only when my app shown in recent apps menu. If I remove my app from the recent apps the BroadcastReceiver will stop working.
  How can I keep the BroadcastReceiver in background?</p>
  
  <p>I register the BroadcastReceiver from my main activity (in OnCreate()).</p>
  
  <pre><code>IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
  registerReceiver(receiver, intentFilter);
  
  BroadcastReceiver receiver = new BroadcastReceiver() {
      @Override
      public void onReceive(Context context, Intent intent) {
  
      }   
  };
  </code></pre>