Android之在ubuntu上常用的am、pm命令的总结
adb shell am instrument [options]
作用:启动对instrument实例的监视。
参数[options]:
-e
作用:提供了以键值对形式存在的测试选项。Android中提供了多种键值对,具体参见下表。
举例:-e class com.android.phone.FIncomingCallTests#testRejectCall
-r
作用:以原始形式输出测试结果。该选项通常是在性能测试时与-e perf true一起使用。
参数
-w
举例:-w com.android.phone.tests/com.android.phone.runners.FunctionalTestRunner
Key | Value | Description |
---|---|---|
package | 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 | The fully-qualified Java class name for one of the test case classes. Only this test case class is executed. | |
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 eitherInstrumentationTestCase 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 inSTDOUT . 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 |
coverageFile |
| 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
|
adb shell am start [options]
作用:启动一个activity
举例:adb shell am start -a com.lt.test.action.SECOND
举例:adb shell am start -n com.lt.test/.MyActivity
说明:[options]与
adb shell am startservice [options]
作用:启动一个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
举例:adb shell am force-stop com.lt.test
adb shell am broadcast [options]
作用:发送一个广播
举例: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]
作用:列举出所有包含
举例:adb shell pm list packages com.lt
说明:[options]与
adb shell中的am pm命令,一些自己的见解和大多数官网的翻译。
先说下am命令,am全称activity manager,你能使用am去模拟各种系统的行为,例如去启动一个activity,强制停止进程,发送广播进程,修改设备屏幕属性等等。当你在adb shell命令下执行am命令:
am
你也可以在adb shell前执行am命令:
adb shell am start -a android.intent.action.VIEW
关于一些am命令的介绍:
start [options]
startservice [options]
force-stop
kill [options]
kill-all :杀死所有的后台进程。
broadcast [options]
instrument [options]
profile start
profile stop
set-debug-app [options]
clear-debug-app :清空之前用set-debug-app命令设置的package包应用。
以下命令查看官网:
monitor [options]
screen-compat [on|off]
display-size [reset|
display-density
to-uri
to-intent-uri
接下来介绍pm命令,pm全称package manager,你能使用pm命令去模拟android行为或者查询设备上的应用等,当你在adb shell命令下执行pm命令:
pm
你也可以在adb shell前执行pm命令:
adb shell pm uninstall com.example.MyApp
关于一些pm命令的介绍:
list packages [options]
list permission-groups :打印所有已知的权限群组。
list permissions [options]
list features :设备特性。硬件之类的性能。
list libraries :当前设备支持的libs。
list users :系统上所有的users。(上面提到的USER_ID查询方式,如:UserInfo{0:Primary:3}那么USER_ID为0)
path
install [options]
uninstall [options]
clear
enable
disable
disable-user [options]
grant
revoke
set-install-location
get-install-location :返回当前的安装位置。返回结果同上参数选项。
set-permission-enforced
create-user
remove-user
get-max-users :该设备所支持的最大USER数。(某些设备不支持该命令)
更多相关文章
- Android O system函数执行reboot命令失败
- svn在linux下的使用(svn命令行)
- Android选项卡的几种实现方法
- 我的Android进阶之旅------>Android之选项卡(TabHost)的功能和用
- android模拟器命令大全
- Android之adb命令
- Android开发中用到的命令——不常用就忘记了
- java代码控制layout_Margin参数
- android:通过Android命令自动编译出build.xml文件