Android Shell Common Command collation

Source: Internet
Author: User

1. Instruction

Screencap/mnt/sdcard/1234.png

2. Resolution Acquisition

adb shell Dumpsys window displays or adb shell Dumpsys window

Results such as: init=1080x1920 480dpi cur=1080x1920 app=1080x1920 rng=1080x1005-1920x1845 (need to be super-searched)

3. Get the current app's package and activity name (Python 2.7 required)

A, applicable to the following version 4.2
I=os.popen (' adb shell dumpsys activity '). Read (). Split (' Running activit ') [1].split ('} ') [1].split (') [-1]
b, applicable to more than 4.1 version
I=os.popen ("adb Shell Dumpsys Input | Findstr focusedapplication "). Read (). Split () [5]

4, Monitoring the memory consumption of an application

adb shell Dumpsys meminfo packagename

5. Monitor CPU Usage

ADB Shell Dumpsys Cpuinfo

6. Get all Package names

ADB shell PM List Packages

7. Get the System app package name

ADB shell PM List packages-s

8. Get the third-party app package name

ADB shell PM List packages-3

9. Get the application installation package path corresponding to the package name

ADB shell pm List packages-f PackageName all applications
ADB shell PM List packages-3-F packagename third-party applications
ADB shell PM List packages-s-F packagename System Application

10. Clear Application Data

ADB shell pm Clear PackageName

11. Close the application

Am Force-stop PackageName

12. Send Broadcast

AM broadcast [options] <INTENT>
such as: adb shell am Broadcast-a "action_finish" (send a broadcast to close an activity)
ADB shell am broadcast-a Android.intent.action.MASTER_CLEAR (Factory reset method that clears all memory contents)

13. View the size of the folder space

Du-c-K View the size of all files under the path and calculate the sum, in kilobytes

14, waiting for the ADB device access (no device when the plug process, the device will return a null value)

ADB wait-for-device

15. Filter Output
linux:| grep xxx
DOS: | findstr xxx or | Findstr "XXXX"

16. Log Record

Logcat-d Log for some time before printing, auto exit Logcat

Logcat *:e Print only log above e-level (e replaceable)

Logcat-s XXX only filter out the XXX related log

Logcat-f redirect log output (e.g. to file), similar to ">>", but better than ">>" compatibility

17. Self-contained control method

Input KeyEvent <key code number or name> executes a key command, such as "adb shell input keyevent keycode_power" or "adb shell input KeyEvent 26 "
Input tap <x> <y> execute a click command, such as "adb shell input tap 800 800"
Input swipe <x1> <y1> <x2> <y2> perform sliding instructions
Input text "text content" type, need focus first, cannot have space
Am Start Pack Package name/Activity name launch app
ADB shell am Start--activity-single-top-n Package name/activity name toggle the active Name page of the app that was launched
ADB shell am START-W-N Package name/activity name launch app and calculate startup time

18. Get files from Android

ADB pull <remote> <local>

19. write files to Android

ADB push <local> <remote>

20. Install the App

ADB install path/xxx.apk
-R Forced installation
-S mount to SDcard (some phones are not available)

21. Uninstall App

ADB uninstall PackageName

22. Delete Files

RM path/xxx

23. Delete Folder

Rm-r Path

24. Create a file

> path/xxx
Touch path/xxx

25. Create a Folder

mkdir Path

Android Shell Common Command collation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.