i start an android app with "adb.exe shell" as follow and this works fine:
shell am start -a android.intent.action.VIEW -n mypackage/.myActivity
How can I provide a parameter to the command and how can I read it in my app ?
shell am start -a android.intent.action.VIEW -n mypackage/.myActivity <PARAMETER>
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String myParameter=getHowtoReadaParamter();
Android Debug Bridge (adb) is a versatile command-line tool that lets you communicate with a device. The adb command facilitates a variety of device actions, such as installing and debugging apps, and it provides access to a Unix shell that you can use to run a variety of commands on a device.
From am
help:
-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...
--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...
--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...
--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...
--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...
--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...
--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>
--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]
--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]
--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]
So you can send a string parameter like this:
shell am start -a android.intent.action.VIEW -n mypackage/.myActivity -e param value
and read it in activity:
getIntent().getStringExtra("param")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With