Transferred from: http://www.growingwiththeweb.com/2014/01/handy-adb-commands-for-android.html
View connected device (s)
Use the To view all connected devices and list their IDs.
ADB devices
If multiple devices is attached, use to adb -s DEVICE_ID
target a specific device.
Install an application
Use install
the command to install an APK, the optional -r
argument reinstalls and keeps any data if the application is a Lready installed on the device.
Install -install -R ~/application.apk
Uninstall an application
ADB uninstall package_name# exampleadb Uninstall Com.growingwiththeweb.example
Start an activity
ADB shell am start package_name/activity_in_packageadb shell am start package_name/-N com.growingwiththeweb.example/-N com.growingwiththeweb.example/ Com.growingwiththeweb.example.MainActivity
Entering the device ' s shell
ADB shell
Take a screenshot
Sergei Shvetsov came up with a nice one liner so takes a screenshot with and shell screencap
outputs it to a local directory using Perl. Checkouthis Blog for an explanation.
Perl ' s/\x0d\x0a/\x0a/g ' > Screen.png
Power button
This command sends the power button event to turn the device on or off.
26
Unlock screen
This command sends the event, unlocks the lockscreen on the device. It can be combine with the power button command above to turn on and unlock the device.
82
Print all installed Packages
ADB shell PM List packages-f
Logging
To show the log stream on your command line.
ADB logcat
Filter by TagName
ADB logcat---s TEST MYAPP
Filter by priority
To show logs of a specific priority warning and above.
" *:P riority " "*:w"
Here is the priority levels:
V
-Verbose (Lowest priority)
D
-Debug
I
-Info
W
-Warning
E
-Error
F
-Fatal
S
-Silent (highest priority, on which nothing is ever printed)
Filter by TagName and priority
ADB logcat--s Test:w
Filter using
grep
Alternatively the output of logcat
can is piped to on grep
a system that supports it.
grep " Search_term " grep"search_term_1\| Search_term_2"grep"Exception " grep " exception\| Error"
Clearing the
logcat
Buffer
Use the-to-clear the buffer to remove any old log data.
ADB logcat-c
Further reading
See more details on the official adb
reference site.
Go Handy adb commands for Android