Basic operation of adb command

1、adb devices

You can check the connected mobile phone or emulator, if there is an extra 127.0.0.1:5555 offline at this time

You can use adb kill-server, and then use adb devices to view it.

2. If there are multiple devices that can pass adb -s device number, specify which device, and then write the corresponding command.

List of devices attached
cf082842        device
emulator-5554   device

如:adb -s cf082842 shell am force-stop com.ecmoban.android.ecoprint

3. View the startup name and package name
adb shell dumpsys window windows | findstr mFocusedApp

View the package name and startup name of the uninstalled app

Aapt dump badging The path of the package (just drag the package file directly into the cmd command line)

Package name: package: name='com.pagoda.buy'
Launchable-activity: name='com.pagoda.buy.ui.splash.WelcomeActivity2'

4. Check the package
adb shell pm list package installed on the phone

5. Open an application
adb shell am start -n package name / class name of the Activity class

6. Put an application in the background
adb shell input keyevent 3 package name

7. Forcibly close an application
adb -s cf082842 shell am force-stop com.ecmoban.android.ecoprint

8. Get the app start time
adb shell am start -W com.yly.drawpic/.MainActivity
    explanation:
        ThisTime: Start Activity (current application interface) time
        TotalTime: App start time [Follow]
        WaitTime: System start application time (total consumption Time)

Specify a mobile phone -s device number
adb -s cf082842 logcat -v time> F:\logs\applogs\1log.txt

9, windows view port number occupied
netstat -ano | findstr "port number"
according to the pid found above to see which service program occupied
tasklist|findstr "PID"
kill the process taskkill /f /pid PID number

10. Send files to mobile phone
adb push Computer file path/file to be sent Mobile phone storage path
Example:
    Send the desktop xx.png to the mobile phone sdcard directory
    adb push C:\Users\win\Desktop\xx.png /sdcard
    
11. Pull files from the mobile phone
adb pull the path of the mobile phone/pull the file name The path of the computer storage file
Example:
     Send the xx.png file in the /sdcard directory of the phone to the computer desktop
     adb pull /sdcard/xx.png C:\Users\win\Desktop

12. Put the app in the background

adb shell input keyevent 3

If it does not work on a real machine, remember to check the USB debugging (security settings) in the developer options

 

Guess you like

Origin blog.csdn.net/qq_25162431/article/details/115012972