18

Android android.intent.action.BOOT_COMPLETED Intent is not received if I use the "Restart" or "Reboot", but works if I turn off and on the device. Is there Any way to make this work?

Sergey Shustikov
  • 15,377
  • 12
  • 67
  • 119
TibiG
  • 819
  • 1
  • 6
  • 18

5 Answers5

37

Add

<action android:name="android.intent.action.QUICKBOOT_POWERON" /> 

also

Giru Bhai
  • 14,370
  • 5
  • 46
  • 74
  • This is for broadcast receiver? Thanks! – Ruchir Baronia Feb 04 '16 at 03:36
  • 1
    Just a doubt may be a little off topic but will the alarm set by an app need to be reset after a reboot/restart? Please help I am not very much familiar with Android. – Rajesh K Dec 15 '18 at 11:32
  • @RajeshK Restart in Broadcast receiver. – Giru Bhai Dec 15 '18 at 12:06
  • 2
    Thanks. But since Android 8 only `BOOT_COMPLETED` broadcast is allowed? How should I solve this issue? Since `QUICKBOOT_POWERON` is not longer allowed. – Rajesh K Dec 15 '18 at 12:08
  • 10
    Is there any reference to QUICKBOOT_POWERON in the official documentation ? I searched but couldn't find one. But it works, I added it myself in the manifest and the code and Android recognized it. – VSim Apr 13 '19 at 16:09
  • yes, @RajeshK I also desperately need to reregister notifications the user scheduled....or perhaps send notifications from servers to FCM api to have phone reregister daily in case a reboot? I am not sure how to do this as users won't be happy since they scheduled the reminder to go off. – Dean Hiller Aug 11 '20 at 04:13
  • 2
    Is this still useful nowadays to use `android.intent.action.QUICKBOOT_POWERON` ? If not, from which API ? – android developer Aug 17 '20 at 10:01
6

Kindly add the below Permission:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

and add the Receiver Class entry in manifest.zml:

<receiver android:name="com.example.receivers.BootReceiver" >

Now Receiver Class:

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BootReceiver extends BroadcastReceiver {

  private static final String TAG = "Boot Receiver:::";
   /*
    * (non-Javadoc)
    * 
    * @see android.content.BroadcastReceiver#onReceive(android.content.Context,
    * android.content.Intent)
    */
    @Override
    public void onReceive(Context context, Intent intent) {
      if (intent != null) {
        if (intent.getAction().equalsIgnoreCase(
                Intent.ACTION_BOOT_COMPLETED)) {

            //Boot Receiver Called
        }
      }
    }
 }

Now Clean and Run your Application. Hope This class will be called after you power on/off or restarting the device. let me know your feedback.

Sivakumar
  • 633
  • 4
  • 9
3

Add <action android:name="android.intent.action.QUICKBOOT_POWERON" /> this permission in manifest file.

0

add android:priority="100", launch onReceive approximately through 30с

<receiver android:name="..." android:exported="true">
    <intent-filter android:priority="100">
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>
Arman
  • 25
  • 7
0

I use the following permission:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

And inside you "application" block:

<receiver
    android:label="SystemEventReceiver"
    android:name=".SystemEventReceiver"
    android:enabled="true"
    android:exported="false">
    <intent-filter android:priority="1000">
        <category android:name="android.intent.category.DEFAULT"/>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
        <action android:name="android.intent.action.REBOOT"/>
        <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
        <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
        <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
        <action android:name="android.intent.action.MY_PACKAGE_UNSUSPENDED"/>
    </intent-filter>
</receiver>

Make sure android:exported="false" and not "true" or the system will not send the broadcast to your app.

agirardello
  • 2,895
  • 22
  • 22