Reputation: 11645
I have a command which starts an android app (apk) per shell command, which works great.
shell am start -a android.intent.action.VIEW -n mypackage/.MyActivity
How can I pass an argument to that command, which I can read in my app again ?
shell am start -a android.intent.action.VIEW -n mypackage/.MyActivity <MyArgument>
and howto read the parameter in the activity ?
sMyParam = getIntent().getExtras().getString("MyArgument");
Upvotes: 8
Views: 9204
Reputation: 5302
As per this document you can use -e
option for String.
shell am start -a android.intent.action.VIEW -e KEY VALUE -n mypackage/.MyActivity
Upvotes: 2
Reputation: 4869
Read the docs for specifying intents with shell commands.
The bits of most likely interest to you are:
-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE>
Add string data as a key-value pair.
--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE>
Add boolean data as a key-value pair.
--ei <EXTRA_KEY> <EXTRA_INT_VALUE>
Add integer data as a key-value pair.
Upvotes: 5