Using the 'am'-Tool (Start Activities/Intens from a shell)
Description:
Android come with a "toolbox" shell and some tools to interact with the runtime/dalvikvm. One of these tools is "am", an Activity/Intent Manager/Messenger. am can be used to tryout intent from the command line, or to start activities (even with custom parameters).
The "full" documentation of am.
- Code: Select all
./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>
"start" will kick an intent. We just need to know what kind of intent we need.
Let's assume you have an activity "de.rtjava.andtest.myview.A1" and the package "de.rtjava.andtest" then you'll start the activity with
- Code: Select all
adb shell
# am start -n de.rtjava.andtest/de.rtjava.andtest.myview.A1
or with
- Code: Select all
adb shell am start -n de.rtjava.andtest/de.rtjava.andtest.myview.A1
This will start the requested activity. Ideal for ant or shell scripts (including .bat files)
So how about an location?
- Code: Select all
adb shell am start 'geo:0,0?q=Munich,Germany'
Or the web?
- Code: Select all
adb shell am start 'http://www.wikipedia.org'
Or edit your first contact?
- Code: Select all
adb shell am start -a android.intent.action.EDIT -n 'com.google.android.contacts/com.google.android.contacts.EditContactActivity' -d 'content://contacts/people/1'
Don't forget to look at the LogCat to find out what intents are sent.
[EDIT]Reworked and added more samples[/EDIT]









