title: Broadcast context-registered receiver not working
body: <p>I want an app to send a broadcast to a several other apps. And I am not managing to make it work :-(</p>
  
  <p>In the app sending the broadcast I simply do:</p>
  
  <pre><code>        sendBroadcast((new Intent("myBusiness.intent.action.MY_ACTION"))
              .putExtra("some_extra_data", "the_extra_data"), "my_receiver_permission");
  </code></pre>
  
  <p>In the apps that are supposed to receive the broadcast I use context-registered receivers to minimize system load but it is not working... The apps are targeting SDK 26 and I've tested it on several versions... I declare a member variable in the MainActivity class to hold the receiver being registered:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  ...
      public static BroadcastReceiver mMyReceiver = null;
  ...
  }
  </code></pre>
  
  <p>I register and unregister the receiver in the onCreate() and onDestroy() methods:</p>
  
  <pre><code>    @Override
      protected void onCreate(Bundle savedInstanceState) {
          ...
          if (savedInstanceState == null) {
              ...
              this.registerReceiver(mMyReceiver = new MyReceiver(),
              new IntentFilter("myBusiness.intent.action.MY_ACTION"),
              "my_receiver_permission", null);
              ...
          }
      }
  
      @Override
      protected void onDestroy() {
          ...
          if (mMyReceiver != null)
              this.unregisterReceiver(mMyReceiver);
      }
  </code></pre>
  
  <p>And have declared the receiver class:</p>
  
  <pre><code>public class MyReceiver extends BroadcastReceiver {
      public MyReceiver() {
          super();
      }
  
      @Override
      public void onReceive(Context context, Intent intent) {
          // And here is where I would like to do my stuff...
      }
  }
  </code></pre>
  
  <p>As I am using permissions I think that the order of apps installation may be important. So what I am doing is that I am first installing, and executing and closing, the "receiving" apps. Then I install and execute the "broadcasting" app, and close it. And finally I execute one of the "receiving" apps expecting the Broacastreceiver.onReceive() to trigger... but no...</p>
  
  <p>Following Roey's comment I incorporated the receiver in the Manifest and sent the Broadcast using the FLAG_INCLUDE_STOPPED_PACKAGES flag. What made it work if I don't use permissions to protect the receiver. But it still doesn't work if I use permissions :-( This is how the Manifest looks like:</p>
  
  <pre><code>&lt;manifest ...&gt;
  ...
      &lt;uses-permission android:name="my_receiver_permission" /&gt;
      &lt;permission android:name="my_receiver_permission"/&gt;
  ...
      &lt;application ...&gt;
  ...
          &lt;receiver
              android:name=".MyReceiver"
              android:enabled="true"
              android:exported="true"
              android:permission="my_receiver_permission"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="myBusiness.intent.action.MY_ACTION" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
  ...
       &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Any idea why it is not working?? Thaaank yoouuuu</p>