adb shell am 的功能
adb shell am 使用此命令可以从cmd控制台启动 activity, services;发送 broadcast等等:
C:\Users\Administrator>adb shell am
usage: am [subcommand] [options]

    start an Activity: am start [-D] [-W]
        -D: enable debugging
        -W: wait for launch to complete

    start a Service: am startservice

    send a broadcast Intent: am broadcast

    start an Instrumentation: am instrument [flags]
        -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
        -e : set argument to
        -p : write profiling data to
        -w: wait for instrumentation to finish before returning

    start profiling: am profile start
    stop profiling: am profile stop

    start monitoring: am monitor [--gdb ]
        --gdb: start gdbserv on the given port at crash/ANR

    specifications include these flags:
        [-a ] [-d ] [-t ]
        [-c [-c ] ...]
        [-e|--es ...]
        [--esn ...]
        [--ez ...]
        [-e|--ei ...]
        [-n ] [-f ]
        [--grant-read-uri-permission] [--grant-write-uri-permission]
        [--debug-log-resolution]
        [--activity-brought-to-front] [--activity-clear-top]
        [--activity-clear-when-task-reset] [--activity-exclude-from-recents]
        [--activity-launched-from-history] [--activity-multiple-task]
        [--activity-no-animation] [--activity-no-history]
        [--activity-no-user-action] [--activity-previous-is-top]
        [--activity-reorder-to-front] [--activity-reset-task-if-needed]
        [--activity-single-top]
        [--receiver-registered-only] [--receiver-replace-pending]
        []

使用实例: 如启动一个 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


 

更多相关文章

  1. GitHub 标星 2.5K+!教你通过玩游戏的方式学习 VIM!
  2. 如何在后台运行Linux命令?
  3. No.11 使用firewall配置的防火墙策略的生效模式
  4. 使用Android(安卓)Studio编译Fresco
  5. Android(安卓)后台任务(四)Loader
  6. Ubuntu 14.04下搭建 Android(安卓)开发环境(1) -JDK安装
  7. 深入了解Android图形管道-part1
  8. android新增语言的方法(墨西哥的西班牙语)
  9. android 系统启动过程中加入tcpdump和logcat

随机推荐

  1. Mysql连接数设置和获取的方法
  2. Mysql中索引和约束的示例语句
  3. sqoop export导出 map100% reduce0% 卡住
  4. mysql查询条件not in 和 in的区别及原因
  5. 解决mysql使用not in 包含null值的问题
  6. 解决从集合运算到mysql的not like找不出N
  7. 使用mysql记录从url返回的http GET请求数
  8. hive从mysql导入数据量变多的解决方案
  9. navicat 连接数据库隔段时间后自动断开连
  10. 为什么在MySQL中不建议使用UTF-8