0

I'm trying to catch BOOT_COMPLETED action with that broadcast receiver in manifest:

 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <application>
        <receiver android:name=".domain.broadcast.NightModeBroadcastReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
    </application>

Receiver's code:

class NightModeBroadcastReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context, intent: Intent) {
        Toast.makeText(context, "Work", Toast.LENGTH_LONG).show()
    }
}

When i launch adb shell am broadcast -a android.intent.action.BOOT_COMPLETED it dont react, but with adb shell am broadcast -a android.intent.action.BOOT_COMPLETED com.example.test it show toast. It also don't react after reboot. How can i fix it?

UPD: With adb shell am broadcast -a android.intent.action.BOOT_COMPLETED it shows error system_process W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.BOOT_COMPLETED flg=0x400010 } to com.example.test/com.example.test.domain.broadcast.NightModeBroadcastReceiver

Ra0-0
  • 1
  • 1
  • Check this out https://stackoverflow.com/questions/57833208/cant-start-activity-from-broadcastreceiver-on-android-10 – Zain Mar 01 '23 at 09:02

0 Answers0