16

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
  • 14,165
  • 9
  • 62
  • 113
TibiG
  • 759
  • 1
  • 5
  • 18

3 Answers3

34

Add

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

also

Giru Bhai
  • 14,404
  • 5
  • 45
  • 73
  • This is for broadcast receiver? Thanks! – Ruchir Baronia Feb 04 '16 at 03:36
  • 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
  • 7
    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
  • 1
    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
2

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