# Script to start "am" on the device, which has a very rudimentary# shell.#base=/systemexport CLASSPATH=$base/framework/am.jarexec app_process $base/bin com.android.commands.am.Am "$@"
Command | Description |
start [options] <INTENT> | Start an Activity specified by<INTENT> . See the Specification for <INTENT> arguments. Options are:
|
startservice [options] <INTENT> | Start the Service specified by<INTENT> . See the Specification for <INTENT> arguments. Options are:
|
force-stop <PACKAGE> | Force stop everything associated with <PACKAGE> (the app's package name). |
kill [options] <PACKAGE> | Kill all processes associated with <PACKAGE> (the app's package name). This command kills only processes that are safe to kill and that will not impact the user experience. Options are:
|
kill-all | Kill all background processes. |
broadcast [options] <INTENT> | Issue a broadcast intent. See the Specification for <INTENT> arguments. Options are:
|
instrument [options] <COMPONENT> | Start monitoring with an Instrumentation instance. Typically the target<COMPONENT> is the form<TEST_PACKAGE>/<RUNNER_CLASS> . Options are:
|
profile start <PROCESS> <FILE> | Start profiler on <PROCESS> , write results to <FILE> . |
profile stop <PROCESS> | Stop profiler on <PROCESS> . |
dumpheap [options] <PROCESS> <FILE> | Dump the heap of <PROCESS> , write to <FILE> . Options are:
|
set-debug-app [options] <PACKAGE> | Set application <PACKAGE> to debug. Options are:
|
clear-debug-app | Clear the package previous set for debugging with set-debug-app . |
monitor [options] | Start monitoring for crashes or ANRs. Options are:
|
screen-compat [on|off] <PACKAGE> | Control screen compatibility mode of <PACKAGE> . |
display-size [reset|<WxH>] | Override emulator/device display size. This command is helpful for testing your app across different screen sizes by mimicking a small screen resolution using a device with a large screen, and vice versa. Example: |
display-density <dpi> | Override emulator/device display density. This command is helpful for testing your app across different screen densities on high-density screen environment using a low density screen, and vice versa. Example: |
to-uri <INTENT> | Print the given intent specification as a URI. See the Specification for <INTENT> arguments. |
to-intent-uri <INTENT> | Print the given intent specification as an intent: URI. See the Specification for <INTENT> arguments. |
启动的方法为一个activity
# am start -n 包名/包名.活动(activity)名称启动照相机:
# am start -n com.android.camera/com.android.camera.Camera
启动浏览器
# am start -n com.android.browser/com.android.browser.BrowserActivity
启动浏览器并上网:
#am start -a android.intent.action.VIEW -d http://www.google.cn/
打电话 :
#am start -a android.intent.action.CALL -d tel:10086
profile
#am profile 进程号 start profile_result.txt
#am profile 进程号 stop
启动一个service
#am startservice service的intent
启动instrument测试(界面上是进dev tools -->instrument选择)
看看浏览器测试工程的xml文件
<application>
<uses-library android:name="android.test.runner" />
</application>
<!--
This declares that this app uses the instrumentation test runner targeting
the package of com.android.email. To run the tests use the command:
"adb shell am instrument -w com.android.browser.tests/android.test.InstrumentationTestRunner"
-->
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.android.browser"
android:label="Tests for Browser."/>
<instrumentation android:name="com.android.browser.BrowserLaunchPerformance"
android:targetPackage="com.android.browser"
android:label="Browser Launch Performance">
</instrumentation>
将当前浏览器加到单元测试中
# am instrument -w com.android.Browser/android.test.InstrumentationTestRunner
运行某个TestCase:
# am instrument -w -e class com.android.BrowserTest.PopularUrlsTest com.android.Browser/android.test.InstrumentationTestRunner
运行一个TestCase中的某个功能:
adb shell am instrument -w -e class com.android.BrowserTest.PopularUrlsTest#testStability com.android.Browser/android.test.InstrumentationTestRunner
同时测试多个TestCase:
#am instrument -w -e class com.android.BrowserTest.PopularUrlsTest,TestWebViewClient.java com.android.Browser/android.test.InstrumentationTestRunner
public class ApiDemosRunner extends InstrumentationTestRunner{
@Override
public TestSuite getAllTests(){
Log.i(”ApiDemosRunner”, “ApiDemosRunner::getAllTests()”);
return new TestSuiteBuilder(ApiDemosRunner.class).includeAllPackagesUnderHere().build();
}
@Override
public ClassLoader getLoader(){
return ApiDemosRunner.class.getClassLoader();
}
}