am start

测试中经常会用到am start命令去进行操作,基本上也只用到 am start -n 和 am start -a ** -d **,后来测试activity启动用到了am start -W,才惊觉这个命令的功能还是很强大的,所以总结了一下,存档以备以后查看。


1. am start -n <Activity>
   解释:启动一个activity
   e.g. am start -n com.android.settings/.Settings   启动android原生设置的一级页面
   
2. am start -a <Activity> -d <parameter>
   解释: 启动一个activity同时传入-d后面的参数
   e.g.  am start -a android.intent.action.CALL -d tel:10086   打开拨号盘并拨打电话给10086
         am start -a android.intent.action.VIEW geo:0,0?q=beijing   启动google键盘并定位到北京
 
3. am start -D <Activity>
   解释:将应用设置成可调式模式,打开会提示waiting for debugger,方便调试那些在打开过程中产生的bug。
   
4. am start -W <Activity>
   解释:等待完全启动,并记录了启动时间
   e.g. am start -W com.android.settings/.Settings  应用完全启动,并记录启动时间,结果如下:
   Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.android.settings/.Settings
   Status: ok
   Activity: com.android.settings/.MiuiSettings
   ThisTime: 414
   TotalTime: 718
   WaitTime: 801
   Complete
   
5. am start -P <FILE>
   解释:类似 –start-profiler,不同的是当app进入idle状态,则停止profiling
   
6. am start -S
   解释:启动activity之前,需要先调用forceStopPackage()方法强制停止应用,比如如果activity打开,-n只会重新起一遍activity,-S会杀掉原来的应用,重新启动activity
   
7. am start --opengl-trace
   解释:运行获取OpenGL函数的trace
   
8. am start --user <USER_ID> | current
   解释:指定用户来运行App,默认为当前用户。




am start: start an Activity.  Options are:
    -D: enable debugging
    -W: wait for launch to complete
    --start-profiler <FILE>: start profiler and send results to <FILE>
    --sampling INTERVAL: use sample profiling with INTERVAL microseconds
        between samples (use with --start-profiler)
    -P <FILE>: like above, but profiling stops when app goes idle
    -R: repeat the activity launch <COUNT> times.  Prior to each repeat,
        the top activity will be finished.
    -S: force stop the target app before starting the activity
    --opengl-trace: enable tracing of OpenGL functions
    --user <USER_ID> | current: Specify which user to run as; if not
        specified then run as the current user.
  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值