$ adb devicesIf multiple devices are attached, use adb -s DEVICE_ID to target a specific device
$ adb shell dumpsys activity services$ adb -s xxx.xxx.xx.xxx:5555 install Downloads/com.xxx.android.2.8.0.apk$ adb -s xxx.xxx.xx.xxx:5555 install -r Downloads/com.xxx.android.2.8.0.apkthe optional -r argument reinstalls and keeps any data if the application is already installed on the device. It is helpful in updating the app from current Build(1.0) to next Build(1.1)
$ adb push Downloads/test-copy.rtf /sdcard/test-copy.txt$ adb pull /sdcard/foo.txt Downloads/acd.txt$ adb -s xxx.xxx.xx.xxx:5555 shell$ adb shell ls /system/bin$ adb shell monkey -v -p com.xxxx.android 400Monkey is a program that runs on your emulator/device and generates random streams of user events such as clicks, touches, or gestures in the app.
$ adb logcat####Wireless usage
adb is usually used over USB. However, it is also possible to use over Wi-Fi, as described here.
-
Connect your Android device and adb host computer to a common Wi-Fi network accessible to both. We have found that not all access points are suitable; you may need to use an access point whose firewall is configured properly to support adb. Note: If you are attempting to connect to a Wear device, force it to connect to Wi-Fi by shutting off Bluetooth on the phone connected to it.
-
Connect the device to the host computer with a USB cable.
-
Set the target device to listen for a TCP/IP connection on port 5555.
$ adb tcpip 5555 -
Disconnect the USB cable from the target device.
-
Find the IP address of the Android device. For example, on a Nexus device, you can find the IP address at Settings > About tablet (or About phone) > Status > IP address. Or, on an Android Wear device, you can find the IP address at Settings > Wi-Fi Settings > Advanced > IP address.
-
Connect to the device, identifying it by IP address.
$ adb connect -
Confirm that your host computer is connected to the target device: $ adb devices
List of devices attached
:5555 device
$ adb logcat -s TAG_NAME
$ adb logcat -s TAG_NAME_1 TAG_NAME_2$ adb logcat "*:<priority>"
# Where <priority> can be V (Verbose), D (Debug), I (Info), W (Warning), E (Error), F (Fatal), S (Silent).It can be combined with tagname command, to filter by tagname and priority
$ adb logcat -s TEST: W$ adb logcat | grep "term"
$ adb logcat | grep "term1\|term2"$ adb shell cat /proc/cpuinfo$ adb -s DEVICE_ID shell input keyevent 82$ adb -s DEVICE_ID shell input keyevent 26$ adb -s DEVICE_ID shell pm list packages -f$ adb -s DEVICE_ID shell am start PACKAGE_NAME/ACTIVITY_IN_PACKAGE
$ adb -s DEVICE_ID shell am start PACKAGE_NAME/FULLY_QUALIFIED_ACTIVITY
Examples:
adb -s 192.168.56.101:5555 shell am start -n com.xxxx.android/.activities.MainActivity
adb -s 192.168.56.101:5555 shell am start -n com.xxxx.android/com.xxxx.android.activities.MainActivity$ adb -s DEVICE_ID shell am start -a android.intent.action.VIEW -d http://www.google.com$ adb -s DEVICE_ID shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.pngScreenshot will be stored in you client machine from where you have executed the command. Look into the same directory from where you have executed the command.
$ screenrecord [options] <filename>
Examples :
$adb shell screenrecord /sdcard/demo.mp4Stop the screen recording by pressing Ctrl-C, otherwise the recording stops automatically at three minutes or the time limit set by --time-limit. To begin recording your device screen, run the screenrecord command to record the video. Then, run the pull command to download the video from the device to the host computer.