Highly recommended article: Welcome to collect Android dry goods to share

##### Read five minutes, 10 o ‘clock every day, and learn for life with you. This is Android programmer

This article covers some of the basics of Android development. Here’s what you’ll learn:

How ADB works

Introduction to ADB

ADB (Android Debug Bridge) is a general-purpose command-line tool that allows you to communicate with emulator instances or connected Android devices. It facilitates a variety of device operations, such as installing and debugging applications, and provides access to the Unix shell, which can be used to run various commands on emulators or connected devices. The tool acts as a client-server program.

  • Client, which sends commands. The client runs on the development machine. You can invoke the client from the command line terminal by issuing adb commands.

  • A daemon that runs commands on the device. The daemon runs as a daemon on each emulator or device instance.

  • Server, which manages the communication between the client and the daemon. The server runs as a background process on the development machine.

Adb tool path Android_sdk /platform-tools/

Ii. How ADB works

1. Connect to the Android emulator

ADB binds to local TCP port 5037 and listens for commands sent from ADB clients – all ADB clients use port 5037 to communicate with the ADB server. The server is then set up to connect to all running Android emulators /Android devices.

2. Connect the USB device to an Android device

  • A. Open the Developer option

Settings >About Phone > Click Build Number seven times in a row

  • B. Enable USB debugging

  • C. Enter ADB Devices under Dos to verify whether the mobile phone is connected to ADB

3.WLAN connects to Android devices

This method is not commonly used and is ignored

ADB common commands

1. Install and uninstall apK

  • A. install apk

Adb install apk path

  • B. uninstall apk

Adb unstall APK package name

2. Import or export files to the mobile phone

  • A. Export mobile phone files

adb pull remote local

  • B. Import the file to the mobile phone

adb push local remote

3. Start and stop the ADB service

  • A. Enable the ADB service

adb start-server

  • B. Stop the ADB service

adb kill-server

4. Run the ADB command to take screenshots and videos

  • A. screenshots screencap

Adb Shell Screencap file save path

  • B. screenrecord video

Adb Shell ScreenRecord file save path

Press Control + C to stop screen recording, otherwise recording will stop automatically when three minutes or –time-limit is set.

Screenrecord partial parameters

options instructions
–size width x height Set resolution eg: 1280×720
–bit-rate rate Video bit rate, the default value is 4Mbps, can be set to 6Mbps for better quality eg:adb shell screenrecord --bit-rate 6000000 /sdcard/demo.mp4
–time-limit time Set the maximum recording duration in seconds. The default and maximum values are 180 (3 minutes).

5. Invoke ActivityManager (am command)

  • A. send intent

adb shell am start -a android.intent.action.VIEW

  • B. to start the Activity

Adb shell am start-n Package name/class name

  • C. to start the service

Adb shell am startService Package name/class name

  • D. Broadcast

Adb shell am Boradcast -a broadcasts Action

  • E. Forcibly stop the application

Adb shell force-stop package name

6. Invoke PackageManager (PM command)

  • A. uninstall apk

Adb shell PM uninstall Package name

  • B. View all APK package names on the mobile phone

adb shell pm list packages

  • C. View known rights groups

adb shell pm list permission-groups

  • D. View the mobile phone Feature support

adb shell pm list features

  • E. View the APK installation path based on the package name

Adb shell PM path Package name

  • F. Clear app data

Adb shell PM clear Package name

  • G. Multi-user correlation

Adb shell PM get-max-users Specifies the maximum number of users supported

Example Query all adb shell PM list users of the system

Create a new user adb shell PM create-user user_name

Remove adb shell PM remove-user user_id

7. Dumpsys dumps system data to the screen

  • A. Obtain the current running Activity

adb shell dumpsys activity | findstr Run

  • B. Obtain apK version number and permission informationAdb shell dumpsys package com.xxx.xxx

8. Check the system process of the mobile phone

  • A. Run the Top command to view system processes

adb shell top

  • B. Run the ps command to view system processes

adb shell ps

Findstr searches command filter redundant information the adb shell ps | findstr searches qq

9. Use logcat to capture log information

  • A. Use logcat to capture log information

adb logcat > 1.txt

  • B. Run the -s command to filter log labels

Adb logcat -s focuses on the log tag

  • C. Run -c to clear the cache log

adb logcat -c

10. Power management commands

  • A. Simulate the power disconnect of the device

adb shell dumpsys battery unplug

  • B. Behavior under low power condition

adb shell settings put global low_power 1

  • C. Restore the power supply

adb shell dumpsys battery reset

11. Run adb to enter the recovery mode

You can use the combination key or adb command to enter the Recovery mode. Adb reboot Recovery

12. Skip the Google Boot wizard command

adb shell pm disable com.google.android.setupwizard
adb shell settings put global device_provisioned 1
adb shell settings put secure user_setup_complete 1
Copy the code

Start the boot wizard command


C:\Users\Administrator>adb shell am start  com.google.android.setupwizard/.user.WelcomeActivity
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.google.android.setupwizard/.user.WelcomeActivity }

C:\Users\Administrator>
Copy the code

At this point, this has ended, if there is wrong place, welcome your suggestion and correction. Meanwhile, I look forward to your attention. Thank you for reading. Thank you!