General commands
Connect operation
adb kill-server #Close the adb service
adb start-server #Start adb service
adb tcpip 5555 #Bind port of 5555 to wait client’s connection
adb connect IP_ADRRESS:5555 #Connect to device through network
adb device #List devices connected to the host
adb -s device_serial #Specify the serial number of the device
export ANDROID_SERIAL=device_serial #Set default device by serial
File operation
adb push device_dir host_dir #push files form host to device
adb pull host_dir device_dir #pull files from device to host
Device info
adb devices #View mobile devices
adb shell cat /system/build.prop | grep product #Get mobile phone system information (CPU, manufacturer name, etc.)
adb shell getprop ro.build.version.release #Get the phone system version
adb shell getprop ro.build.version.sdk #Get the api version of the mobile phone system
adb -d shell getprop ro.product.model #Get the model of the mobile phone
adb -d shell getprop ro.product.brand #Get the name of the mobile phone manufacturer
adb get-serialno #Get the serial number of the phone
adb shell getprop ro.serialno #Get the serial number of the phone
adb shell cat /sys/class/net/wlan0/address #Get the mobile phone mac address
adb shell cat /proc/meminfo #Get phone memory information
adb shell df -h #Get mobile phone storage information
adb shell wm density #Get the physical density of the phone
Package operation
adb shell pm list packages #View all package names in the phone
adb shell pm list packages -3 #View all third-party package names in the phone
adb install packsge #install package
adb install -r packages #Keep data and cache files to install new packages
adb uninstall package #Uninstall the package
adb shell pm clear package_name #Clear cache data
adb shell am start -n package_name/activity_name #Start the program
adb shell am force-stop package_name #Force stop the running program
Interaction operation
adb shell text #Input content to the EditText control that gets the focus
adb input keyevent #Send a key command to the system to simulate the key action of the user on the keyboard
adb shell input keyevent 26 #Send a key command to the system to simulate the key action of the user on the keyboard
adb shell input tap 100 100 #Send a tap operation to the device, the parameter is (100,100)
adb shell input swipe 100 100 200 200 300 #Slide from 100 100 to 200 200 after 300 milliseconds
adb shell input swipe 100 100 100 100 1000 #Long press for 1000 milliseconds at the 100 100 position
adb shell monkey -p package name 100 #Generate random events 100 times
adb shell monkey -p package name -v -v 100 #Generate random events 100 times and send detailed activity information
Log operation
adb logcat #View system log
adb logcat -c #Clear the system log buffer
Screenshot operation
adb shell /system/bin/screencap -p /sdcard/xx.png #Take a screenshot and save the file as xx.png on your phone
Functional command
Take pictures
adb shell “am start -a android.media.action.IMAGE_CAPTURE” #Open the camera
adb shell input keyevent 27 #Start taking pictures