The usage of the command line tool am in Android is as follows:
Usage: am [subcommand] [options]
Start an Activity: am start [-D] [-W] <INTENT>
-D: enable debugging
-W: wait for launch to complete
Start a Service: am startservice <INTENT>
Send a broadcast Intent: am broadcast <INTENT>
Start an Instrumentation: am instrument [flags] <COMPONENT>
-R: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
-E <NAME> <VALUE>: set argument <NAME> to <VALUE>
-P <FILE>: write profiling data to <FILE>
-W: wait for instrumentation to finish before returning
Start profiling: am profile <PROCESS> start <FILE>
Stop profiling: am profile <PROCESS> stop
Start monitoring: am monitor [-- gdb <port>]
-- Gdb: start gdbserv on the given port at crash/ANR
<INTENT> specifications include these flags:
[-A <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
[-C <CATEGORY> [-c <CATEGORY>]...]
[-E | -- es <EXTRA_KEY> <EXTRA_STRING_VALUE>...]
[-- Esn <EXTRA_KEY>...]
[-- Ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE>...]
[-E | -- ei <EXTRA_KEY> <EXTRA_INT_VALUE>...]
[-N <COMPONENT>] [-f <FLAGS>]
[-- 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]
[-- Cycler-registered-only] [-- Cycler-replace-pending]
[<URI>]
The start method is an activity.
# Am start-n package name/package name. activity name
Which of the following acitivity methods can be used to locate information from the AndroidManifest. xml file of each application?
Start music
# Am start-n com. android. music/com. android. music. MusicBrowserActivity
Start video
# Am start-n com. android. music/com. android. music. VideoBrowserActivity
# Am start-n com. android. music/com. android. music. MediaPlaybackActivity
Start the camera:
# Am start-n com. android. camera/com. android. camera. Camera
Start the browser
# Am start-n com. android. browser/com. android. browser. BrowserActivity
Start the browser and access the Internet:
# Am start-a android. intent. action. VIEW-d http://www.google.cn/
Call:
# Am start-a android. intent. action. CALL-d tel: 10086
Google map directly locates in Shenzhen:
Am start-a android. intent. action. VIEW geo: 0, 0? Q = shenzhen
Profile
# Ps
# Am profile process no. start profile_result.txt
# Am profile process no. stop
Start a service
# Am startservice service intent
Start the instrument test (dev tools --> select instrument on the Interface)
Check the xml file of the browser test project.
<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>
Add current browser to unit test
# Am instrument-w com. android. Browser/android. test. InstrumentationTestRunner
Run a TestCase:
# Am instrument-w-e class com. android. BrowserTest. PopularUrlsTest com. android. Browser/android. test. InstrumentationTestRunner
Run a function in a TestCase:
Adb shell am instrument-w-e class com. android. BrowserTest. PopularUrlsTest # testStability com. android. Browser/android. test. InstrumentationTestRunner
Test multiple TestCase at the same time:
# 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 ();
}
}