An app cannot start on its own when the device boots. It asks the Android operating system to start it by delivering the broadcast with action BOOT_COMPLETED
. For this purpose the app registers a BroadcastReceiver
with the Android framework and the app must hold the RECEIVE_BOOT_COMPLETED
permission to receive the said broadcast.
On Android 13 and above if you do not grant RUN_ANY_IN_BACKGROUND
permission to an app, it won't be able to start on boot. To know how to remove the background permission see How to stop background apps on Android?
Quoted from the official documentation:
If an app targets Android 13 or higher and is in the "restricted" state, the system doesn't deliver the BOOT_COMPLETED
broadcast until the app is started for other reasons.
So no more steps are needed.
Our first thought is to deny the RECEIVE_BOOT_COMPLETED
permission so that the app is not able to receive the BOOT_COMPLETED
broadcast. But the protection level of the permission is normal. So it's always granted and we cannot change its state.
However some custom ROMs like LineageOS add a corresponding AppOp permission named BOOT_COMPLETED
. If you are on one of such ROMs you can revoke this permission using the appops
commandline tool or elegantly with PermissionManagerX app. See demonstration here how it works with PMX.
BroadcastReceiver is an app component which can be disabled using pm disable
from commandline or elegantly with our upcoming app Ajza. See more details here.
If none if the above options is applicable for you, there is a workaround.
The methods stated above can stop apps from starting on boot only. But an app can also listen to some other broadcast events, or it can keep on restarting if killed, or run in background continuously if it's designed to be so.
So a better approach is to prevent apps from running in background so that they are not able to perform any long running tasks even if they are started on boot or later.
Related: