title: Static BroadcastReceiver not Working after Installation from ADB
body: <p>I working on a project that need to launch an app by broadcasting a customized intent "com.example.demo.action.LAUNCH" via adb. </p>
  
  <p>My plan is to statically register a broadcast receiver "LaunchAppReceiver" that will launch the app when receiving the customized intent.</p>
  
  <p>I installed the .apk by calling </p>
  
  <pre><code>adb install -r &lt;pakcageName&gt;
  </code></pre>
  
  <p>then I sent the intent by calling</p>
  
  <pre><code>adb shell am broadcast -a com.example.demo.action.LAUNCH
  </code></pre>
  
  <p>However, nothing happened after the intent was sent. It seemed the broadcast receiver didn't receive the intent at all. Do I need to somehow instantiate the receiver before it can receive the intent? </p>
  
  <p><strong>Note:</strong> Since the android device is remote, I have to use adb to handle the installation and the launch.</p>
  
  <p>Thanks!!</p>
  
  <hr>
  
  <p>I declared the broadcast receiver as follow</p>
  
  <pre><code>public class LaunchAppReceiver extends BroadcastReceiver{
  
      public LaunchAppReceiver () {}
  
      @Override
      public void onReceive(Context context, Intent intent) {
  
          Intent newIntent = new Intent(context, MainActivity.class);
          newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          context.startActivity(newIntent);
      }
  }
  </code></pre>
  
  <p>and statically registered it in the AndroidManifest.xml. </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.demo" &gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme"
          android:enabled="true"&gt;
          &lt;receiver
              android:name="com.example.demo.LaunchAppReceiver"
              android:enabled="true"
              android:exported="true"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.example.demo.action.LAUNCH"/&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>