Solved [DONE] StartAndroidActivity support more arguments
#1
--edit: New arguments are added in Kodi Nexus v20. 

Currently the StartAndroidActivity only supports the following parameters:
- intent (optional)
- datatype (optional)
- dataURI (optional)

Can we extend it to support all arguments as available with the 'am start' command?
As described in the am command helptext.

am [start|instrument]
am start [-a <action>] [-d ]
[-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>

Mainly the -e parameter, which can be a array of args as the last parameter in the StartAndroidActivity call.

The following line in the libdroidjni project already suggest support for the -e parameters through 'putExtra'
CJNIIntent CJNIIntent::putExtra(const std:Confusedtring &name, const std:Confusedtring &value)

The combination of package/activity (either exactly like that or by another parameter) should also be supported.
Example: com.retroarch/com.retroarch.browser.retroactivity.RetroActivityFuture
Reply
#2
Found in source AndroidBuiltins.cpp

/*! \brief Launch an android system activity.
 *  \param params The parameters.
 *  \details params[0] = package
 *           params[1] = intent (optional)
 *           params[2] = datatype (optional)
 *           params[3] = dataURI (optional)
 *           params[4] = flags (optional)
 *           params[5] = extras (optional)
 *           params[6] = action (optional)
 *           params[7] = category (optional)
 *           params[8] = className (optional)
 */

Perhaps this should be updated to request for comment on how the parameters should be formatted, from the wiki it's generic "StartAndroidActivity(package,[intent,dataType,dataURI])".

I also found the need to send extras to am start, my instance requires multiples f.e. am start -e param1 item1 -e param2 item2

Can we get clarification or an updated wiki. If I assume correct you should be able to pass params[5] as a dict {'param1': 'item1', 'param2': 'item2'} however I haven't attempted this in favor of an os.system call instead.

Clarification would be appreciated.
Reply
#3
@chrisism , noticed that you submitted a pull for this. Thank you!

I'm also unsure about the sintax, could you clarify how to StartAndroidActivity with 1x extras pair (key/value) ?
Reply
#4
(2023-01-18, 01:27)samukas Wrote: @chrisism , noticed that you submitted a pull for this. Thank you!

I'm also unsure about the sintax, could you clarify how to StartAndroidActivity with 1x extras pair (key/value) ?

To be honest, the extras were added by @a1rwulf if I am correct. I simply continued on his work and added some extra arguments, so kudos for him.
The extras are a collection of key value pairs in JSON format, a json string. So it is indeed a bit tricky to get it right, taking care of proper quotes escaping etc. I have an example of how I did this from an addon in python. Hopefully that helps you and gives an example. 
Here are some lines where I build up my arguments and extras: https://github.com/chrisism/script.akl.r...er.py#L325
And here you code where I translate it into the StartAndroidActivity command: https://github.com/chrisism/script.modul...rs.py#L179
Reply
#5
Thanks for your answer, and for pointing me towards @a1rwulf 's work.
This was a tricky one for me to figure out, but this GitHub Pull hinted on how to build the array.

For future reference, the following is working on my side:
xbmc.executebuiltin('StartAndroidActivity("package.name.goes.here","intent.action.goes.here","","http://www.url.goes.here.com/abcde","","[{\"key\": \"fill_key_here\", \"type\": \"string\", \"value\": \"fill_value_here\"}]")')
Reply

Logout Mark Read Team Forum Stats Members Help
[DONE] StartAndroidActivity support more arguments0