Executing a code whenever the device boots up can be crucial in several scenarios. One use can be rescheduling alarms since they are canceled after the device boots up.
Receiving ACTION_LOCKED_BOOT_COMPLETED
when the device is booted but it hasn't been unlocked by the user yet. We unlocked the device to see the toast message.
Receiving ACTION_BOOT_COMPLETED
when the device is booted and it has been unlocked by the user.
If you register the BroadcastReceiver for both ACTION_LOCKED_BOOT_COMPLETED
and ACTION_BOOT_COMPLETED
at the same time, you will receive actions 2 times. Be careful if you have to execute your code only once.
Xiaomi devices require AutoStart manufacturer-specific permission to be able to receive ACTION_LOCKED_BOOT_COMPLETED
or ACTION_BOOT_COMPLETED
actions.