博客
关于我
adb shell am 的用法
阅读量:429 次
发布时间:2019-03-06

本文共 2161 字,大约阅读时间需要 7 分钟。

adb shell am
使用此命令可以从cmd控制台启动 activity, services;发送 broadcast等等:
 
1 C:\Users\Administrator>adb shell am 2 usage: am [subcommand] [options] 3  4     start an Activity: am start [-D] [-W] 
5 -D: enable debugging 6 -W: wait for launch to complete 7 8 start a Service: am startservice
9 10 send a broadcast Intent: am broadcast
11 12 start an Instrumentation: am instrument [flags]
13 -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)14 -e
: set argument
to
15 -p
: write profiling data to
16 -w: wait for instrumentation to finish before returning17 18 start profiling: am profile
start
19 stop profiling: am profile
stop20 21 start monitoring: am monitor [--gdb
]22 --gdb: start gdbserv on the given port at crash/ANR23 24
specifications include these flags:25 [-a
] [-d
] [-t
]26 [-c
[-c
] ...]27 [-e|--es
...]28 [--esn
...]29 [--ez
...]30 [-e|--ei
...]31 [-n
] [-f
]32 [--grant-read-uri-permission] [--grant-write-uri-permission]33 [--debug-log-resolution]34 [--activity-brought-to-front] [--activity-clear-top]35 [--activity-clear-when-task-reset] [--activity-exclude-from-recents]36 [--activity-launched-from-history] [--activity-multiple-task]37 [--activity-no-animation] [--activity-no-history]38 [--activity-no-user-action] [--activity-previous-is-top]39 [--activity-reorder-to-front] [--activity-reset-task-if-needed]40 [--activity-single-top]41 [--receiver-registered-only] [--receiver-replace-pending]42 [
]

 

使用实例:
如启动一个 Activity:
 
格式:adb shell am start -n 包名/包名+类名(-n 类名,-a action,-d date,-m MIME-TYPE,-c category,-e 扩展数据,等)。

实例1:

C:\Users\Administrator>adb shell am start -n com.android.camera/.Camera
Starting: Intent { cmp=com.android.camera/.Camera }
 
实例2:(带extra 的 intent)
C:\Users\Administrator>adb shell am start -n com.android.camera/.Camera -e abc hello
Starting: Intent { cmp=com.android.camera/.Camera (has extras) }
其中 extra 的 key 为 abc ,value 为字串 "hello"
 
还可以发送命令模拟手机低电环境:

实例:

adb shell am broadcast -a android.intent.action.BATTERY_CHANGED --ei "level" 3 --ei "scale" 100

转载地址:http://iepuz.baihongyu.com/

你可能感兴趣的文章
MySQL_西安11月销售昨日未上架的产品_20161212
查看>>
Mysql——深入浅出InnoDB底层原理
查看>>
MySQL“被动”性能优化汇总
查看>>
MySQL、HBase 和 Elasticsearch:特点与区别详解
查看>>
MySQL、Redis高频面试题汇总
查看>>
MYSQL、SQL Server、Oracle数据库排序空值null问题及其解决办法
查看>>
mysql一个字段为空时使用另一个字段排序
查看>>
MySQL一个表A中多个字段关联了表B的ID,如何关联查询?
查看>>
MYSQL一直显示正在启动
查看>>
MySQL一站到底!华为首发MySQL进阶宝典,基础+优化+源码+架构+实战五飞
查看>>
MySQL万字总结!超详细!
查看>>
Mysql下载以及安装(新手入门,超详细)
查看>>
MySQL不会性能调优?看看这份清华架构师编写的MySQL性能优化手册吧
查看>>
MySQL不同字符集及排序规则详解:业务场景下的最佳选
查看>>
Mysql不同官方版本对比
查看>>
MySQL与Informix数据库中的同义表创建:深入解析与比较
查看>>
mysql与mem_细说 MySQL 之 MEM_ROOT
查看>>
MySQL与Oracle的数据迁移注意事项,另附转换工具链接
查看>>
mysql丢失更新问题
查看>>
MySQL两千万数据优化&迁移
查看>>