这些命令主要用于分析日志,查看系统信息等。一下主要做介绍,详细使用查看相应帮助。
1. logcat
查看日志,如果需要打印时间,加参数-v time
adb logcat -v time
2.bugreport
会有从开机之后详细的dumpsys,dumpstate和logcat信息,是一份完整的日志记录。对分析用户行为,异常信息,系统状态有很大的参考作用
adb bugreport > xxx.log
3. dumpsys命令
查看各种系统信息,从堆栈信息,内存信息,wifi信息 等各种信息一应俱全。
adb shell dumpsys
Also you can apply filters to running services:
1 SurfaceFlinger
2 accessibility
3 account
4 activity
5 alarm
6 appwidget
7 audio
8 backup
9 battery
10 batteryinfo
11 bluetooth
12 bluetooth_a2dp
13 clipboard
14 connectivity
15 content
16 cpuinfo
17 device_policy
18 devicestoragemonitor
19 diskstats
20 dropbox
21 entropy
22 ethernet
23 hardware
24 input_method
25 iphonesubinfo
26 isms
27 keybar
28 location
29 media.audio_flinger
30 media.audio_policy
31 media.camera
32 media.player
33 meminfo
34 mount
35 netstat
36 network_management
37 notification
38 package
39 permission
40 phone
41 power
42 search
43 sensorservice
44 simphonebook
45 statusbar
46 telephony.registry
47 throttle
48 uimode
49 usagestats
50 vibrator
51 wallpaper
52 wifi
53 window
例如:
查看某个应用的具体内存信息
adb shell dumpsys meminfo packagename
查看堆栈的信息
adb shell dumpsys activity
4. top
查看进程信息
top -m 5 -t
5. am
可用于查看指定应用
usage: am [subcommand] [options]
start an Activity: am start [-D] <INTENT>
-D: enable debugging
send a broadcast Intent: am broadcast <INTENT>
start an Instrumentation: am instrument [flags] <COMPONENT>
-r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
-e <NAME> <VALUE>: set argument <NAME> to <VALUE>
-p <FILE>: write profiling data to <FILE>
-w: wait for instrumentation to finish before returning
start profiling: am profile <PROCESS> start <FILE>
stop profiling: am profile <PROCESS> stop
<INTENT> specifications include these flags:
[-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
[-c <CATEGORY> [-c <CATEGORY>] ...]
[-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
[--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
[-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
[-n <COMPONENT>] [-f <FLAGS>] [<URI>]
启动的方法为
am start -n 包(package)名/包名.活动(activity)名称
启动的方法可以从每个应用的AndroidManifest.xml的文件中得到
Music 和 Video(音乐和视频)的启动方法为:
am start -n com.android.music/com.android.music.MusicBrowserActivity
am start -n com.android.music/com.android.music.VideoBrowserActivity
am start -n com.android.music/com.android.music.MediaPlaybackActivity
Camera(照相机)的启动方法为:
am start -n com.android.camera/com.android.camera.Camera
Browser(浏览器)的启动方法为:
am start -n com.android.browser/com.android.browser.BrowserActivity
启动浏览器 :
am start -a android.intent.action.VIEW -d http://www.google.cn/
拨打电话 :
am start -a android.intent.action.CALL -d tel:10086
启动 google map 直接定位到北京 :
am start -a android.intent.action.VIEW geo:0,0?q=beijing
adb shell am start -n com.aliyun.SecurityCenter/.ui.SecurityCenterActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000
adb shell am start -n com.aliyun.mobile.permission/.ExternalMainActivity -a yunos.intent.action.PERMISSION_MAIN -c android.intent.category.DEFAULT