Android_adb shell am/pm使用

转自: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

时间: 2024-11-08 08:17:34

Android_adb shell am/pm使用的相关文章

adb shell am pm 用法

Using activity manager (am) Within an adb shell, you can issue commands with the activity manager (am) tool to perform various system actions, such as start an activity, force-stop a process, broadcast an intent, modify the device screen properties,

adb shell am命令

adb shell am命令是在cmd命令行可以通过命令来启动Activity,Boradcast,Service等,更多使用可以参考下面附件. 比如在cmd串口我们发送广播,广播action是"com.cmcc.media.bufferring" ,并且带key是"url",value是"http://www.baidu.com" 的数据给广播接收者,如下即可am broadcast -a "com.cmcc.media.buffer

关于android studio UID_CHANGED错误

最近使用android studio碰到个莫名其妙的问题,就是在run的时候无法加载到虚拟机或者是真机,对此我google和百度了下,有的说删除data里面的数据,有的说手机回复出厂设置,但是对我 来说这些都不行. 重装了好几次as,问题依然存在,求各位支个招,能不重装系统就尽量不重装. 以下是错误码: local path: F:\work\Test\app\build\outputs\apk\app-debug.apk remote path: /data/local/tmp/com.exa

INSTALL_FAILED_OLDER_SDK

Uploading file local path: /Users/Rubert/Android/workspace/MyApplication/app/build/outputs/apk/app-debug.apk remote path: /data/local/tmp/com.example.rubert.firstdemo Installing com.example.rubert.firstdemo DEVICE SHELL COMMAND: pm install -r "/data/

Android群英传笔记——第九章:Android系统信息和安全机制

Android群英传笔记--第九章:Android系统信息和安全机制 本书也正式的进入尾声了,在android的世界了,不同的软件,硬件信息就像一个国家的经济水平,军事水平,不同的配置参数,代表着一个android帝国的强弱,所以厂商喜欢打配置战,本节就要是讲 Android系统信息的获取 PackageManager的使用 ActivityManager的使用 Android安全机制 一. Android系统信息的获取 由于android手机的开源性,手机的配置各种各样,那些优化大师之类的东西

usb调试停用系统应用-利用adb命令

最近天猫魔盒上的应用都被删了,我个人猜测是系统更新了一个应用程序去定时删除应用,而这些被删除的应用在一个列表中 所以从两个方面考虑破解 1.删除列表 2.删除程序 由于不知道列表以什么方式存在,所以暂时考虑第2条 步骤: 1.魔盒上打开usb远程调试 2.电脑连接 adb connect 192.168.1.110(魔盒ip),adb shell 3.pm list packages -f   列出所有包名 4.查找分析,找出删除应用的程序 5.停用之:pm block com.android.

Installation error: INSTALL_FAILED_MEDIA_UNAVAILAB

报错如下: [2012-06-21 12:56:17 - xmobile17] Installation error: INSTALL_FAILED_MEDIA_UNAVAILABLE [2012-06-21 12:56:17 - xmobile17] Please check logcat output for more details. [2012-06-21 12:56:18 - xmobile17] Launch canceled! 解决: adb shell pm set-instal

[uiautomator篇] 如何获取apk的包名 博客模板

Android自动化学习笔记:获取APK包名的几种方法 ---------------------------------------------------------------------------------------------------------------------------- 小记:自学过程中,经常需要用得到一个APK的包名,总结一下得到包名的几种方式. ********************** 2017-16-23:初版 ********************

如何设置安卓手机软件的默认安装位置

1.通过ADB shell命令 下面为安卓4.4版本的adb shell命令 pm get-install-location: returns the current install location. 0 [auto]: Let system decide the best location 1 [internal]: Install on internal device storage 2 [external]: Install on external media pm set-instal