Home > Software engineering >  RECEIVE_BOOT_COMPLETED not received on Android 11
RECEIVE_BOOT_COMPLETED not received on Android 11

Time:02-20

I'm rebooting the phone and I expect a log message. I've registered the BroadcastReceiver in Androidmanifest, but no message is being received. What am I Missing?

androidmanifest:

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


    <!-- Receives an event when the device has completed a reboot -->
    <receiver
        android:name=".BootReceiver"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <category android:name="android.intent.category.DEFAULT"/>
            <action android:name="android.intent.action.BOOT_COMPLETED"/>
            <action android:name="android.intent.action.BOOT" />
            <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
            <action android:name="android.intent.action.QUICKBOOT_POWERON" />
        </intent-filter>
    </receiver>

BootReceiver:

class BootReceiver : BroadcastReceiver() {
    override fun onReceive(p0: Context, p1: Intent) {
        Log.i("BootReceiver", "Boot event received")
    }
}

When I filter in the logging for "boot" I see several other apps logging the event, but not my own App:

I/NU.LockBootCompleteReceiver: onReceive : Intent { act=android.intent.action.LOCKED_BOOT_COMPLETED flg=0x89000010 cmp=com.samsung.android.app.telephonyui/.netsettings.ui.receiver.LockBootCompleteReceiver (has extras) }
I/BCL@CoreSvc: (CoreServiceComponentEnabler) updateComponent() : class com.samsung.android.bixby.receiver.token.BootCompleteReceiver | 2
I/BCL@CoreSvc: (CoreServiceComponentEnabler) updateComponent() : class com.samsung.android.bixby.receiver.token.LazyBootCompleteReceiver | 1
I/CIDManager: [onReceive(BootReceiver.java:20)] onReceive: android.intent.action.LOCKED_BOOT_COMPLETED
I/ActivityManager: Start proc 7201:com.samsung.android.game.gametools/u0a79 for broadcast {com.samsung.android.game.gametools/com.samsung.android.game.gametools.floatingui.receiver.GameBoosterBootCompleteReceiver}
I/GameTools: BootCompleteReceiver already enabled.
I/GameTools: GameBoosterBootCompleteReceiver: onReceive: Intent.ACTION_LOCKED_BOOT_COMPLETED
I/GameTools: GameBoosterBootCompleteReceiver: clear runtime settings on boot complete.
I/GameTools: GameBoosterBootCompleteReceiver: register Intent.ACTION_USER_UNLOCKED
I/GameTools: GameBoosterBootCompleteReceiver: register Intent.ACTION_USER_UNLOCKED via EventDelegationManager
I/ORC/FbeBootReceiver: onReceive : android.intent.action.LOCKED_BOOT_COMPLETED
I/ORC/FbeBootReceiver: FBE islocked : true
I/CS/MsgFMMReceiverService: PCW LOCK. handlePCWLockMessage. LockedBootComplete : true
I/CS/xmsFbeJobService: onLockedBootCompleted()
I/ORC/FbeMigrationJobService: onLockedBootCompleted()
I/StateUtils: isDirectBootMode On : true
I/PackageManager: !@Start postBootUpdate
I/PackageManager: !@Finish postBootUpdate dexopted: 3

CodePudding user response:

Remove:

<category android:name="android.intent.category.DEFAULT"/>

Categories are normally only used on activities, not broadcasts.

CodePudding user response:

The code above is working fine. I have checked on device -> google pixel 4a, os 12 mi a1, os 11

i am able to see logs every time i reboot my device. Try changing your device and test.

check the manifest.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapplication">

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


    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyApplication">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


        <receiver
            android:name=".BootReceiver"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <category android:name="android.intent.category.DEFAULT"/>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
                <action android:name="android.intent.action.BOOT" />
                <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
            </intent-filter>
        </receiver>

    </application>

</manifest>
  • Related