-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathLaunchArgsParser.java
More file actions
31 lines (26 loc) · 978 Bytes
/
LaunchArgsParser.java
File metadata and controls
31 lines (26 loc) · 978 Bytes
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
package com.reactnativenavigation.utils;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
public final class LaunchArgsParser {
private static final String LAUNCH_ARGS = "launchArgs";
/**
* Parses launch args passed to activity intent to WritableMap
* @param activity to fetch the extra launch args
* @return parsed writable map if it exist, otherwise empty map will be returned
*/
public static WritableMap parse(Activity activity) {
if (activity != null) {
Intent intent = activity.getIntent();
if (intent != null) {
Bundle launchArgs = intent.getBundleExtra(LAUNCH_ARGS);
if (launchArgs != null) {
return Arguments.fromBundle(launchArgs);
}
}
}
return Arguments.createMap();
}
}