Tuesday, March 2, 2010

Running android application from command line using "am start ..." command

If you are a programmer you would like to run your application on android device form command line instead of clicking on the icon. So here is the solution for invoking your applications.

Use "am" command on command prompt. You can go to device's shell terminal by issuing "adb shell" command or you can club the am command with adb shell as "adb shell am start...". Following is the syntax for "am command".


> adb shell am
usage: am [start|instrument]
       am start [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
                [-c <CATEGORY> [-c <CATEGORY>] ...]
                [-e <EXTRA_KEY> <EXTRA_VALUE> [-e <EXTRA_KEY> <EXTRA_VALUE> ...]
                [-n <COMPONENT>] [-D] [<URI>]
       am instrument [-e <ARG_NAME> <ARG_VALUE>] [-p <PROF_FILE>]
                [-w] <COMPONENT>
For example, to start the Contacts application you can use
> adb shell am start -n com.google.android.contacts/.ContactsActivity

Refer to Instrumentation testing on android open source site
 

No comments:

Post a Comment