My automated test sends intents via adb shell am
, but I'm having trouble specifying an extra that is a String Array.
According to the Intent class docs, it is possible to put an String[] extra to an intent.
However the Intent specification docs for the am
command does not list a string array type. The only string types I can see in the docs is normal string and perhaps null "string":
--esn <EXTRA_KEY>
Add a null extra. This option is not supported for URI intents.
-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE>
Add string data as a key-value pair.
Is it avoidable to write a java application for the mere purpose of sending string arrays?
Is there a way to send a String[] extra from the command line?
edit in case this is not possible this way, what is the preferred way to do this?
Using putExtra() We can start adding data into the Intent object, we use the method defined in the Intent class putExtra() or putExtras() to store certain data as a key value pair or Bundle data object. These key-value pairs are known as Extras in the sense we are talking about Intents.
Using putExtra() and getExtras() in android Intents are asynchronous messages which allow Android components to request functionality from other components of the Android system. For example an Activity can send an Intents to the Android system which starts another Activity .
This example demonstrate about How to send data from one activity to another in Android without intent. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
The Binder transaction buffer has a limited fixed size, currently 1MB, which is shared by all transactions in progress for the process.
Old question, but unanswered.adb shell am
shows all the options, among them there's:
[--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]
(to embed a comma into a string escape it using "\,")
For anyone else looking for this the command line flags for extras are listed below
-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE>
--esn <EXTRA_KEY>
--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...]
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