- adb is a very important debugging tool for Android mobile terminals.
- This article introduces commonly used adb commands
Article directory
-
- 1. Start the application: adb shell am start
- 2. Use the browser to open the specified URL: adb shell am start
- 3. Kill the application process adb shell am force-stop/adb shell am kill
- 4. Delete all application data: adb shell pm clear package
- 5. Get the list of installed applications on the device: adb shell pm list package
- Appendix: [adb detailed tutorial] series of articles table of contents
(I have uploaded the adb installation package to the network disk. You can directly search the official account [Essential Skills for Software Testing] or slide to the bottom of the article, click on the official account card to scan the QR code, and go to Follow to receive it.)
- For the installation and setting of ADB, please refer to the previous article on the blog:
adb detailed tutorial (1) - download, installation and environment variable configuration
adb detailed Tutorial (2) - Turn on the mobile developer mode and connect the Android device through adb - Installing and uninstalling apps using ADB has been introduced in the previous article, so I won’t go into details again
adb detailed tutorial (3) - Using adb to install and uninstall apps
1. Start the application: adb shell am start
- The application can be started directly through the adb command, but you need to know the full path of the application's startup activity.
- The command template is as follows:
adb shell am start { 包名}/{ 启动activity}
If you don’t know the startup activity of your application, you can try the following method:
- Use the adb command "adb logcat -c" to clear the logs
- Then use the adb command "adb logcat ActivityManager:I *:S", which will print out the activity information running on the device.
- Start application
- Because the command to clear the log has been executed before, it is easy to find the first activity started by the application.
- After you have the package name and the startup activity, you can run the command to start the application:
adb shell am start com.tencent.qqmusic/com.tencent.qqmusic.activity.AppStarterActivity
2. Use the browser to open the specified URL: adb shell am start
- You can use the adb command to command the device to open the specified URL through the browser.
adb shell am start -a android.intent.action.VIEW -d { URL}
- Example:
adb shell am start -a android.intent.action.VIEW -d https://www.csdn.net/
- The result will be displayed after success
3. Kill the application process adb shell am force-stop/adb shell am kill
- You can kill the application process on the device through adb command
- Kill the process of the specified application
adb shell am force-stop { 包名}
- Kill all background processes.
adb shell am kill-all
- Example:
adb shell am force-stop com.tencent.qqmusic
- This command does not display results, but if the specified application is running on the device at this time, you can see that the application has been closed.
- This command does not display results, but if the specified application is running on the device at this time, you can see that the application has been closed.
4. Delete all application data: adb shell pm clear package
- You can delete all application data through the adb command:
adb shell pm clear { 包名}
- Example
adb shell pm clear com.tencent.qqmusic
- After success, "Success" will be printed.
5. Get the list of installed applications on the device: adb shell pm list package
- You can obtain the list of installed applications on the device through the adb command:
adb shell pm list packages { 选项} { 关键字}
- {options} and {keywords} are optional
- If {keyword} is filled in, applications whose package names contain keywords will be output.
- {Options} specifically include the following:
- -f: View associated files.
- -d: Filter to show only deactivated packages.
- -e: Filter to show only enabled packages.
- -s: Filter to show only system packages.
- -3: Filter to show only third-party packages.
- -i: View the package installer.
- -u: Include uninstalled packages.
- –user user_id: The user space to be queried.
- Example:
- Search by keyword
adb shell pm list packages samsung
- The printed application list all contains the keyword "samsung"
- Search by keyword
Appendix: [adb detailed tutorial] series of articles table of contents
adb detailed tutorial (1) - download, installation and environment variable configuration
adb detailed tutorial (2) - enable mobile developer mode and connect Android devices through adb< a i=2>adb detailed tutorial (3) - Use adb to install and uninstall app ————————————————————— ——————————
I have uploaded the adb installation package to the public account of the same name of the blog I run [Essential Skills for Software Testing]. The public will also upload test-related information from time to time and can collect it if necessary.
If necessary, please click on the QR code below the article to get it~