title: Android: sending LocalBroadcastManager's intents from BroadcastReceiver events
body: <p>I'm having a strange situation, where an intent receiver is registered with LocalBroadcastManager either from service or from MainActivity, and when intent is sent from PHONE_STATE receiver (defined in AndroidManifest.xml), it's never received.</p>
  
  <p>A "self-test" with sending same intent from activity|service - works.</p>
  
  <p>Is it worth trying to specify LocalBroadcastManager's intent to be received via AndroidManifest.xml?</p>
  
  <hr>
  
  <p>Service is defined as:</p>
  
  <pre><code>    &lt;service
       android:name=".AppService"
       android:process=":remote"&gt;
        &lt;intent-filter&gt;
         &lt;action android:name="me.cmp.app.AppService" /&gt;
        &lt;/intent-filter&gt;
      &lt;/service&gt;
  </code></pre>
  
  <p>In service:</p>
  
  <pre><code> public class AppService extends Service {
   @Override
   public void onCreate() {
          super.onCreate();
          LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("me.cmp.app.statechange"));
  
              // self-test uses same intent sending code:
              Intent intent2 = new Intent("me.cmp.app.statechange");
              intent2.putExtra("message", "selfsend");
              LocalBroadcastManager.getInstance(this).sendBroadcastSync(intent2);
  
   }  
   ...
  </code></pre>
  
  <p>In manifest:</p>
  
  <pre><code>    &lt;receiver android:name="me.cmp.app.PhoneReceiver" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.PHONE_STATE" &gt;
              &lt;/action&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;        
  </code></pre>
  
  <p>Listener:</p>
  
  <pre><code>public class PhoneReceiver extends BroadcastReceiver {
  
    @Override
    public void onReceive(Context context, Intent intent) {
      Bundle extras = intent.getExtras();
      if (extras != null) {
        Log.e("test", extras.getString(TelephonyManager.EXTRA_STATE));
  
        Intent intent2 = new Intent("me.cmp.app.statechange");
        intent2.putExtra("message", state.toString());
        LocalBroadcastManager.getInstance(context).sendBroadcastSync(intent2);
        Log.w("test", "Broadcast sent");
      }
    }
  }
  </code></pre>
  
  <p>--</p>
  
  <p>The main problem seems to be <a href="https://stackoverflow.com/questions/4311069/should-i-use-android-process-remote-in-my-receiver/4413816#4413816">Should I use android: process =&quot;:remote&quot; in my receiver?</a> ; <em>however I'm still not sure why MainActivity's receiver didn't worked earlier, maybe fully qualified names are a must</em>.</p>