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.
- Shut down event broadcasts "
com.htc.intent.action.QUICKBOOT_POWEROFF
" - Restart(reboot) event broadcasts "
android.intent.action.ACTION_SHUTDOWN
" - 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
How to Pop Fragment Off Backstack
Android Listview Setselection() Does Not Seem to Work
Set Font for All Textviews in Activity
Android Spannablestring Set Background Behind Part of Text
Start a Fragment via Intent Within a Fragment
Render Error in Android Studio 3.0 Layout Editor
Webview Textarea Doesn't Pop Up the Keyboard
Disable Soft-Keyboard from Edittext But Still Allow Copy/Paste
Android - Build a Notification, Taskstackbuilder.Addparentstack Not Working
How to Attach Android Source to Eclipse
Add Elevation/Shadow on Toolbar for Pre-Lollipop Devices
Android Kitkat 4.4 Hangouts Cannot Handle Sending Sms Intent
How to Change Color of Listview Items on Focus and on Click
Android Screen Lock/ Unlock Programmatically
Video Streaming Using Rtsp: Android
Android Device Does Not Show Up in Adb List