android.intent.action.BOOT_COMPLETED Intent is not received at "Restart" or "Reboot"
Asked Answered
E

5

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?

Emotion answered 22/7, 2014 at 8:52 Comment(1)
Add " <action android:name="android.intent.action.QUICKBOOT_POWERON" /> " also.Boracite
B
37

Add

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

also

Boracite answered 22/7, 2014 at 9:16 Comment(7)
This is for broadcast receiver? Thanks!Candor
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.Naphthyl
@RajeshK Restart in Broadcast receiver.Boracite
Thanks. But since Android 8 only BOOT_COMPLETED broadcast is allowed? How should I solve this issue? Since QUICKBOOT_POWERON is not longer allowed.Naphthyl
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.Lawless
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.Which
Is this still useful nowadays to use android.intent.action.QUICKBOOT_POWERON ? If not, from which API ?Schooner
S
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.

Sidero answered 22/7, 2014 at 9:14 Comment(4)
that's what I've originally did.Emotion
then this will work perfectly.. put log in onReceive.. and test it.. else post your manifest and receiver classSidero
<action android:name="android.intent.action.QUICKBOOT_POWERON" /> is the solution Giru Bhai already exposed.Emotion
Where does the Receiver class go, please?Sumac
M
3

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

Misstate answered 22/7, 2014 at 9:20 Comment(0)
C
1

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.

Chambray answered 27/8, 2023 at 10:13 Comment(0)
E
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>
Electrothermal answered 24/3, 2023 at 11:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.