This article will introduce how to disable or enable an app with the adb command in Android.
1. Disable an app: adb shell pm disable --user USER_ID PACKAGE
The following command will change the package com.google.android.youtube
to disabled
state.
$ adb shell pm disable-user --user 0 com.google.android.youtube
Success
You can check whether the status has been changed to disabled
with the following command. enabled=3
means disabled from the logs.
$ adb shell dumpsys package com.google.android.youtube
Packages:
Package [com.google.android.youtube] (3d1fcc2):
userId=10121
pkg=Package{b77ead3 com.google.android.youtube}
codePath=/product/app/YouTube
flags=[ SYSTEM HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP KILL_AFTER_RESTORE RESTORE_ANY_VERSION LARGE_HEAP ]
....
User 0: ceDataInode=122910 installed=true hidden=false suspended=false distractionFlags=0 stopped=false notLaunched=false enabled=3 instant=false virtual=false
User 0 means a user of the system(Owner), and when multi-users are created, other user spaces are created like User 10 and User 11.
2. Enable an app: adb shell pm enable --user USER_ID PACKAGE
The following command changes the com.google.android.youtube
package to the enabled state.
$ adb shell pm enable --user 0 com.google.android.youtube
Package com.google.android.youtube new state: enabled
You can check whether the status has changed to enabled with the following command. enabled=1
means enabled from the logs.
$ adb shell dumpsys package com.google.android.youtube
Packages:
Package [com.google.android.youtube] (3d1fcc2):
userId=10121
pkg=Package{b77ead3 com.google.android.youtube}
codePath=/product/app/YouTube
flags=[ SYSTEM HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP KILL_AFTER_RESTORE RESTORE_ANY_VERSION LARGE_HEAP ]
....
User 0: ceDataInode=122910 installed=true hidden=false suspended=false distractionFlags=0 stopped=false notLaunched=false enabled=1 instant=false virtual=false
3. Change the app to the default state
The following command changes the App to the default state.
The default state means that it will be enabled or disabled based on the enabled attribute value in the App's AndroidManifest.xml
Normally, since Application is not set to android:enabled=false
in App, it will mostly be enabled with default state.
$ adb shell pm default-state --user 0 com.google.android.youtube
Package com.google.android.youtube new state: default
You can check whether it has changed to the default state with the following command. enabled=0
means enabled from the logs.
$ adb shell dumpsys package com.google.android.youtube
Packages:
Package [com.google.android.youtube] (3d1fcc2):
userId=10121
pkg=Package{b77ead3 com.google.android.youtube}
codePath=/product/app/YouTube
flags=[ SYSTEM HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP KILL_AFTER_RESTORE RESTORE_ANY_VERSION LARGE_HEAP ]
....
User 0: ceDataInode=122910 installed=true hidden=false suspended=false distractionFlags=0 stopped=false notLaunched=false enabled=0 instant=false virtual=false
4. Component's enabled/disabled/default states
You can change the app's component(Activity, Service, Provider, and Receiver) state to disabled, enabled, or default state. You can do this with previous command set, but you need to pass component name instead of package name.
You can change the state of a component like this:
$ adb shell pm disable-user --user 0 com.google.android.youtube/com.google.android.youtube.MainActivity
$ adb shell pm enable --user 0 com.google.android.youtube/com.google.android.youtube.MainActivity
$ adb shell pm default-state --user 0 com.google.android.youtube/com.google.android.youtube.MainActivity
When checking whether the state of a component has been changed, you can check enabledComponents
and disabledComponents
in the package information as follows.
Included in this list means enable or disable status. If it is not included in this list, it means the default state.
$ adb shell dumpsys package com.google.android.youtube
Packages:
Package [com.google.android.youtube] (3d1fcc2):
userId=10121
pkg=Package{b77ead3 com.google.android.youtube}
....
User 0: ceDataInode=122910 installed=true hidden=false suspended=false distractionFlags=0 stopped=false notLaunched=false enabled=0 instant=false virtual=false
gids=[3003]
runtime permissions:
android.permission.ACCESS_FINE_LOCATION: granted=false, flags=[ USER_SENSITIVE_WHEN_GRANTED|USER_SENSITIVE_WHEN_DENIED]
enabledComponents:
com.google.android.youtube.ManageNetworkUsageActivity
disabledComponents:
androidx.work.impl.background.systemalarm.RescheduleReceiver
Related Posts
- How to download and build Android 13, AOSP
- Notification permission request, pop up notification in Android 13
- Resolve `Access blocked: ComponentInfo` error on Android 13
- Fix error "android gradle plugin requires java 11 to run. you are currently using java 1.8."
- Android - Vibration, Vibrator, VibrationEffect example
- How to get phone number in Android
- How to create Bugreports and Logcat with ADB in Android
- Clear application user data with ADB in Android
- How to disable/enable apps with ADB in Android
- How to find PID of a package with adb in Android
- How to grant/revoke permissions with adb in Android
- How to install an apk(app) with adb in Android
- How to kill a process/package from ADB in Android
- How to transfer files using adb push/pull command in Android
- How to capture the screen from adb in Android
- How to uninstall/install system apps from adb in Android
- How to change Settings values from adb in Android
- How to Factory reset with ADB in Android
- How to get logcat from ADB command in Android
- How to capture Heap Dump from app with ADB in Android
- How to force stop an app with adb in Android
- How to start/stop a service from adb in Android
- How to send/broadcast an intent from adb command in Android
- How to start an activity from adb in Android
- How to generate input from adb in Android
- How to check SQLite DB table in Android Studio
- How to get memory info and thread list from adb in Android
- Android - Uri, Scheme and SSP(Scheme Specific Part)
- How to parse a xml file with XmlResourceParser in Android
- Android - Signing an apk with Platfom key
- How to fix "Cleartext HTTP ... not permitted" for Android development
- How to fix "kvm permission denied" for Android Emulator
- Using ADB over Wifi for Android development