title: Android: Boot Complete only works if I launch App Immediately
body: <p>I'm trying to reset alarms in my app and using a receiver to get onBootCompleted. To see if the intent was received, I'm using a toast. The toast only appears if I immediately open the app. Otherwise, the toast does not appear. I looked at previous questions but almost all of them involve services, which I am not using. I am not sure if that is a part of the problem.</p>
  
  <p>Android Manifest</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  android:installLocation="internalOnly"
  package="package.name" &gt;
  
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
  &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
      &lt;activity
          android:configChanges="orientation|screenSize|keyboardHidden"
          android:name=".MainActivity"
          android:label="@string/app_name"
          android:launchMode="singleTop" &gt;
          &lt;meta-data android:name="android.app.searchable"
              android:resource="@xml/searchable" /&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;intent-filter&gt;
              &lt;action android:name="android.intent.action.SEARCH" /&gt;
          &lt;/intent-filter&gt;
  &lt;/activity&gt;
      &lt;receiver android:name=".AlarmReceiver" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.ALARM_SERVICE" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
      &lt;receiver android:name=".AlarmReset"android:enabled="true" android:exported="true"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
              &lt;category android:name="android.intent.category.DEFAULT" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>Receiver Class</p>
  
  <pre><code>public class AlarmReset extends BroadcastReceiver {
  
  @Override
  public void onReceive(Context context, Intent intent)
  {
  
      Toast.makeText(context, "Hello! Got message",
              Toast.LENGTH_LONG).show();
  //reset alarms etc. No service set.
  }
  </code></pre>
  
  <p>I also tried writing the manifest receiver as</p>
  
  <pre><code>&lt;receiver android:name=".AlarmReset" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  </code></pre>
  
  <p>Key points I found online were to include permissions (which I did) and to watch out for logging.</p>
  
  <p>What I do not understand is why it works if I immediately (within a few seconds, otherwise the toast does not appear) start my activity but is unsuccessful otherwise. I am considering testing a few possibilities like launching the activity itself through code or using a service like most others have. I am currently testing on Android 4.4 on an actual phone.</p>