Add support for getLaunchArgs on Android
**Usage:**
1. **Pass** args in order to run the application on the device using ADB or xcrun or Detox:
- Detox: `device.launchApp(bundleId,{launchArgs: {'-key1': 'val1'}})` must use launchArgs key, see [docs](https://github.com/wix/Detox/blob/master/docs/APIRef.DeviceObjectAPI.md#7-additional-launch-arguments).
- ADB: `adb shell am start -n com.yourpackage/com.yourpackage.YourActivity --es launchArgs "{some stringyfied json}"`
- Xcrun: `/usr/bin/xcrun simctl launch ${udid} ${bundleId} --args -key1 value1 -key2 value2`
2. **Retrieve** the arguments: `const launchArgs = await Navigation.getLaunchArgs();`
- There is a small difference between platforms on how they pass the launch args:
- on iOS, the args will be passed as an array of pairs (argv,argc)
- on Android, the args will be passed in the form of a dictionary
Extract args as a dictionary example:
```javascript
const launchArgs = await Navigation.getLaunchArgs();
let resultArgs = {};
if (Platform.OS === 'android') {
resultArgs = launchArgs; // no need to proccess its a dictionary
} else {
for (let i = 0; i < launchArgs.length; i += 2) {
if (i + 1 < launchArgs.length) {
resultArgs[launchArgs[i]] = launchArgs[i + 1];
}
}
}
```
|
|
||
| 1 |
|
1 |
|
| 2 |
|
2 |
|
|
3 |
|
|
| 3 |
|
4 |
|
| 4 |
|
5 |
|
| 5 |
|
6 |
|
|
|
||
| 72 |
|
73 |
|
| 73 |
|
74 |
|
| 74 |
|
75 |
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
| 75 |
|
81 |
|
| 76 |
|
82 |
|
| 77 |
|
83 |
|
|
|
||
|
1 |
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|