title: How to get the `BroadcastReceiver` instance which is defined in `AndroidManifest.xml`
body: <p>I have a <code>BroadcastReceiver</code> in my app, and it was defined in <code>AndroidManifest.xml</code> as below:</p>
  
  <pre><code>&lt;receiver android:name=".receiver.MyTaskReceiver"&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="xxx.xxx.xxx" /&gt;
      &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p>This is the <code>MyTaskReceiver</code> code :</p>
  
  <pre><code>public class MyTaskReceiver extends BroadcastReceiver {
  
      private ReceiverListener listener ;
  
      @Override
      public void onReceive(Context context, Intent intent) {
          //do general things
  
          if(listener != null) {
              listener.received();    //do special things if the listener is setted up.
          }
      }
  
      public void setListener(ReceiverListener listener) {
          this.listener = listener;
      }
  
      public interface ReceiverListener {
          void received();
      }
  
  } 
  </code></pre>
  
  <p>When the receiver got a intent, I will do some general things first, like save data... </p>
  
  <p>But if the specified activity is displayed to the user, I need to do change the activity's views, so I use the <code>ReceiverListener</code> to do this. Set a listener to the <code>MyTaskReceiver</code> in <code>onCreate</code> and set <code>null</code> in <code>onDestroy</code>.</p>
  
  <p>Then here comes an issue, how can to get the instance of the <code>MyTaskReceiver</code> so that I can set a listener to it?</p>
  
  <p>Or is there any other ways to achieve what I want ?</p>
  
  <p>Thanks.</p>