Skip to content

Instantly share code, notes, and snippets.

@dostalleos
Forked from vtarantik/adb.sh
Created July 22, 2020 12:52
Show Gist options
  • Save dostalleos/0258bc3ad8f60c3f12c35792748a78fe to your computer and use it in GitHub Desktop.
Save dostalleos/0258bc3ad8f60c3f12c35792748a78fe to your computer and use it in GitHub Desktop.
//Restart adb in case the device is ie. invisible
adb kill-server; adb start-server
//Install single .apk file
adb install *.apk
//Install multiple apks at once (for split apks)
adb install-multiple 1.apk 2.apk
//Uninstall application
adb uninstall [com.package.name]
//Open logcat where [level] is one of
V: Verbose (lowest priority)
D: Debug
I: Info
W: Warning
E: Error
F: Fatal
S: Silent (highest priority, on which nothing is ever printed)
adb logcat *:[level]
//Simulates the keypress/event from the user. Codes can be found here: https://developer.android.com/reference/android/view/KeyEvent
adb shell input keyevent
//Run activity with a specified package name
adb shell am start -n com.package.name/.ActivityName
//List package names installed on a device
adb shell 'pm list packages -f'
//Get Android version of the device
adb shell getprop ro.build.version.release
//Get Android API level of the device
adb shell getprop ro.build.version.sdk
//Start activity with a category and a flag
adb shell am start -a android.intent.action.MAIN -c android.intent.category.HOME -f 268435456
//Clear app data
adb shell pm clear my.app.package.name
//Control density and screen size of the device
adb shell wm
usage: wm [subcommand] [options]
wm size [reset|WxH|WdpxHdp]
wm density [reset|DENSITY]
wm overscan [reset|LEFT,TOP,RIGHT,BOTTOM]
wm scaling [off|auto]
wm screen-capture [userId] [true|false]
wm size: return or override display size.
width and height in pixels unless suffixed with 'dp'.
wm density: override display density.
wm overscan: set overscan area for display.
wm scaling: set display scaling mode.
wm screen-capture: enable/disable screen capture.
wm dismiss-keyguard: dismiss the keyguard, prompting the user for auth if necessary.
//Force stop the app
adb shell am force-stop com.my.app.package
//Switch adb to root
adb root
//Disable the app (should run as a root)
adb shell pm disable com.google.android.tvlauncher
//Rotate the screen
adb shell settings put system accelerometer_rotation 0
adb shell settings put system user_rotation 0-3
//Get screen orientation
adb shell dumpsys input | grep 'SurfaceOrientation' | awk '{ print $2 }'
//Show battery stats
adb shell dumpsys batterystats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment