b = system_app_name.setArgument(argumentʃ, valueʅ);
The
SystemApp.setArgument function adds an argument to a
SystemApp object. The argument will later be used when the system application is
executed. The string expression
argument and the optional string or numeric expression
value are processed differently on Android and Windows platforms.
The function returns a logical value of 1 (true).
On Android, a system application is typically an Android activity. Each argument will be part of the "extras" passed in the
Intent Bundle that opens the activity. If
value is a string expression, it will be put as a
String extra associated with the name
argument. If
value is a numeric expression, it will be put as a
double extra associated with the name
argument. If
value is not specified, a null String extra will be used. There is special processing for three
argument types:
// get directions to the U.S. Census Bureau using Google Maps
SystemApp google_maps_navigation;
google_maps_navigation.setArgument("action", "android.intent.action.VIEW");
google_maps_navigation.setArgument("data", "google.navigation:q=U.S.+Census+Bureau");
google_maps_navigation.exec("com.google.android.apps.maps");
References to files can
be shared with the other application by calling the
System.getSharableUri action and passing the resulting URI as the
"data" argument.
On Windows, a system application is an executable program. On Windows, every argument is turned into a command line argument passed to the executable. If an argument is provided without a corresponding value and the argument contains spaces and is not wrapped in quotes, the argument will be surrounded by quotes so that it is processed as a single argument by the executable. If a value is provided, then the argument and value are concatenated and will not be surrounded by quotes. If value is numeric, it will be converted to a string.
// plays the song in Windows Media Player, becoming:
// wmplayer.exe "Quick Escape.mp3"
SystemApp windows_media_player;
windows_media_player.setArgument("Quick Escape.mp3");
windows_media_player.exec("wmplayer.exe");
// opens the Census Bureau website in Chrome's Incognito mode, becoming:
// chrome.exe --args --incognito https://www.census.gov
SystemApp chrome;
chrome.setArgument("", "--args --incognito");
chrome.setArgument("https://www.census.gov");
chrome.exec("chrome.exe");