Android Action_Shutdown Broadcast Not Working

ACTION_SHUTDOWN not getting called from Broadcast Receiver on android Q (10) and higher

In the Android official documentation states that As of Build.VERSION_CODES#P this broadcast is only sent to receivers registered through Context.registerReceiver link here

The solution is to delete the ShutdownReceiver from the AndroidManifest.xml and register it using Context.registerReceiver like this:

val shutdownReceiver = ShutdownReceiver();
val bootIntentFilter = IntentFilter(Intent.ACTION_SHUTDOWN);
context.registerReceiver(shutdownReceiver, bootIntentFilter);

BOOT_COMPLETE and ACTION_SHUTDOWN never call the BroadcastReceiver

I found out why it didn't work.
Since I use a HTC device, the broadcast messages are different from others.

  1. Shut down event broadcasts "com.htc.intent.action.QUICKBOOT_POWEROFF"
  2. Restart(reboot) event broadcasts "android.intent.action.ACTION_SHUTDOWN"
  3. Power on event broadcasts "com.htc.intent.action.QUICKBOOT_POWERON"

In other device, when shutting down the device, it might broadcast "android.intent.action.QUICKBOOT_POWEROFF".



Related Topics



Leave a reply



Submit