转自:http://blog.sina.com.cn/s/blog_51335a0001017ux5.html

adb shell am instrument [options] <COMPONENT>

作用:启动对instrument实例的监视。

参数[options]:

-e <key> <value> // -e选项需要放在-w选项之前

作用:提供了以键值对形式存在的测试选项。Android中提供了多种键值对,具体参见下表。
举例:-e class com.android.phone.FIncomingCallTests#testRejectCall

-r

作用:以原始形式输出测试结果。该选项通常是在性能测试时与-e perf true一起使用。

参数 <COMPONENT>:

-w <test_package_name>/<runner_class> //<test_package_name>和<runner_class>在测试工程的AndroidManifest.xml中查找

作用:保持adb shell打开直至测试完成
举例:-w com.android.phone.tests/com.android.phone.runners.FunctionalTestRunner

<key> <value>参考表

Key Value Description
package <Java_package_name> The fully-qualified Java package name for one of the packages in the test application. Any test case class that uses this package name is executed. Notice that this is not anAndroid package name; a test package has a single Android package name but may have several Java packages within it.
class <class_name> The fully-qualified Java class name for one of the test case classes. Only this test case class is executed.
<class_name>#method name A fully-qualified test case class name, and one of its methods. Only this method is executed. Note the hash mark (#) between the class name and the method name.
func true Runs all test classes that extend InstrumentationTestCase.
unit true Runs all test classes that do not extend either InstrumentationTestCase orPerformanceTestCase.
size [small | medium |large] Runs a test method annotated by size. The annotations are @SmallTest,@MediumTest, and @LargeTest.
perf true Runs all test classes that implement PerformanceTestCase. When you use this option, also specify the -r flag for am instrument, so that the output is kept in raw format and not re-formatted as test results.
debug true Runs tests in debug mode.
log true Loads and logs all specified tests, but does not run them. The test information appears in STDOUT. Use this to verify combinations of other filters and test specifications.
emma true Runs an EMMA code coverage analysis and writes the output to/data//coverage.ec on the device. To override the file location, use thecoverageFile key that is described in the following entry.

Note: This option requires an EMMA-instrumented build of the test application, which you can generate with the coverage target.

coverageFile <filename>

Overrides the default location of the EMMA coverage file on the device. Specify this value as a path and filename in UNIX format. The default filename is described in the entry for the emma key

adb shell am start [options] <INTENT>

作用:启动一个activity

举例:adb shell am start -a com.lt.test.action.SECOND

举例:adb shell am start -n com.lt.test/.MyActivity

说明:[options]与<INTENT>参见 http://developer.android.com/tools/help/adb.html#am

adb shell am startservice [options] <INTENT>

作用:启动一个service

举例:adb shell am startservice -a com.lt.test.action.ONESERVICE
举例:adb shell am startservice -n com.lt.test/.MyService

adb shell am force-stop <PACKAGE>
作用:强制关闭一个应用程序

举例:adb shell am force-stop com.lt.test

adb shell am broadcast [options] <INTENT>

作用:发送一个广播
举例:adb shell am broadcast -a "action_finish" (发送一个广播去关闭一个activity)
举例:adb shell am broadcast -a android.intent.action.MASTER_CLEAR(恢复出厂设置的方法,会清除内存所有内容)

举例:adb shell am broadcast -n com.lt.test/.MyBroadcast

adb shell pm list packages [options] <INTENT>

作用:列举出所有包含<INTENT>的package

举例:adb shell pm list packages com.lt

说明:[options]与<INTENT>参见 http://developer.android.com/tools/help/adb.html#pm

参考链接:

http://developer.android.com/tools/help/adb.html

转载于:https://www.cnblogs.com/dirt2/p/5407866.html

Android_adb shell am/pm使用相关推荐

  1. android am发送广播,adb shell am broadcast 手动发送广播及adb shell am/pm其他命令

    在命令行可用adb shell am broadcast -a [action] 手动发送广播 adb shell am [command] 的用法: 首先看一下各部分的作用 adb shell , ...

  2. Android_adb shell dumpsys介绍

    1.dumpsys是Android系统的调试工具,提供有关系统服务的信息,默认打印出当前系统所有service信息,可以在后面加上具体的服务名. 官方介绍:https://developer.andr ...

  3. android+残留软件包名,关于使用pm hide伪卸载系统软件的一些包名

    本帖最后由 北慕城南 于 2017-6-19 09:15 编辑 最新的卫士已经从云端屏蔽了终端的入口,如果你发现你的终端入口没了,只能通过断网->清空360卫士数据来找回 不想使用的系统软件能停 ...

  4. adb echo shell 覆盖_Android ADB命令?这一次我再也不死记了!【简单说】

    adb的全称为Android Debug Bridge.是android司机经常用到的工具.但是问题是那么多命令写代码已经够费劲了,过段时间在次使用时压根记不住呀.本次的大餐就是为此开篇的.这一次我们 ...

  5. android代码shell命令申请权限,如何授予Android Shell用户更多权限?

    我用ndk构建了一些命令行工具,并在/ data / local / tmp中执行了它.现在,当我在命令行工具中调用一些OpenSLES API时,它提示我"需要android.permis ...

  6. Perl 模块安装总结

    从 1994 年 10 月 17 日发布的 Perl 5.000 起,Perl 增加了模块的概念,用来提供面向对象编程的能力.这是 Perl 语言发展史上的一个里程碑.此后,广大自由软件爱好者开发了大 ...

  7. 使用Android Studio新建Project并建立多个module

    使用Android Studio新建Project并建立多个module 分类: Android 2014-03-29 23:25 187人阅读 评论(0) 收藏 举报 说明:本篇内容涉及如何在AS中 ...

  8. 开发日记-20190709 关键词 读书笔记 《Perl语言入门》Day 6

    Preface 麻麻,今天Perl进度推进了两章,Linux进度推进了一章,我这下班进度.高起来我自己都吓一跳.早点睡觉吧!还有,用知识武装自己,而不是欲望. Content 什么是正则表达式? 正则 ...

  9. 获取安卓应用APK包名的方法

    应用商店按照符合Android标准的原则进行设计,使用包名(Package Name)作为应用的唯一标识.即:包名必须唯一,一个包名代表一个应用,不允许两个应用使用同样的包名.包名主要用于系统识别应用 ...

  10. 【Android】Apk安装方式

    adb ->shell:pm->  (adbd启一个shell执行pm) PackageInstaller->               PackageManagerService

最新文章

  1. 如何強迫 .Net 應用程式輸出英文的例外訊息
  2. C语言面向过程与C++面向对象
  3. redis订阅怎么退出_redis-消息的发布与订阅,高效实现原理详述
  4. python语言实例-采用python进行编程的实例有哪些?
  5. BindingException: Invalid bound statement (not found)问题排查:SpringBoot集成Mybatis重点分析...
  6. 外部工具连接SaaS模式云数仓MaxCompute—ETL工具篇
  7. Android学习一:文件操作
  8. 侧输出流简单应用-打印的完整流程
  9. Mysql数据库简单使用(二)
  10. Python制作AI贪吃蛇,很多很多细节、思路都写下来了!
  11. docker容器不支持中文编码
  12. Apache Hudi入门应用
  13. python定位元素方法_Python+webdriver定位元素的几种方法
  14. 按键精灵注册大漠插件
  15. 小程序代码包大小超出限制的解决办法
  16. 作为一名开发者,要警惕这五个浪费生命的现象
  17. 如何保证战略落地_如何保障企业战略落地实施
  18. win10此计算机未连接到网络,win10提示无法连接到此网络怎么解决
  19. 试编写程序,利用前、中序序列或者后、中序序列唯一确定一棵二叉树。
  20. 电脑内存占用过高怎么解决?

热门文章

  1. Keras:框架架构
  2. python模块导入及属性:import
  3. Sublime Text 3安装、配置和快捷键
  4. 反向传播算法(BP)学习笔记
  5. centos7中Python切换到Python3.x版本(解决常出现的错误)
  6. android rsa最大加密明文大小_Android 登录密码信息进行RSA加密示例
  7. relu函数_激活函数解析:Sigmoid, tanh, Softmax, ReLU, Leaky ReLU
  8. python接口自动化登录后保存个人简介_python接口自动化三(登录及发帖)
  9. JZ7-斐波那契数列
  10. Android 帧动画 (一)