Java Code Examples for com.facebook.react.bridge.Arguments#fromBundle()
The following examples show how to use
com.facebook.react.bridge.Arguments#fromBundle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HeadlessService.java From react-native-sync-adapter with MIT License | 6 votes |
@Override protected HeadlessJsTaskConfig getTaskConfig(Intent intent) { boolean allowForeground = Boolean.parseBoolean(getString(R.string.rnsb_allow_foreground)); if(allowForeground || !isAppOnForeground(this)) { Bundle extras = intent.getExtras(); WritableMap data = extras != null ? Arguments.fromBundle(extras) : Arguments.createMap(); return new HeadlessJsTaskConfig( TASK_ID, data, Long.valueOf(getString(R.string.rnsb_default_timeout)), allowForeground); } stopSelf(); return null; }
Example 2
Source File: FIRMessagingModule.java From react-native-fcm with MIT License | 6 votes |
private WritableMap parseIntent(Intent intent){ WritableMap params; Bundle extras = intent.getExtras(); if (extras != null) { try { params = Arguments.fromBundle(extras); } catch (Exception e){ Log.e(TAG, e.getMessage()); params = Arguments.createMap(); } } else { params = Arguments.createMap(); } WritableMap fcm = Arguments.createMap(); fcm.putString("action", intent.getAction()); params.putMap("fcm", fcm); params.putInt("opened_from_tray", 1); return params; }
Example 3
Source File: HeartbeatEventService.java From rn-heartbeat with MIT License | 5 votes |
@Nullable protected HeadlessJsTaskConfig getTaskConfig(Intent intent) { Bundle extras = intent.getExtras(); return new HeadlessJsTaskConfig( "Heartbeat", extras != null ? Arguments.fromBundle(extras) : Arguments.createMap(), 5000, true); }
Example 4
Source File: RNCallKeepBackgroundMessagingService.java From react-native-callkeep with ISC License | 5 votes |
@Override protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) { Bundle extras = intent.getExtras(); return new HeadlessJsTaskConfig( "RNCallKeepBackgroundMessage", Arguments.fromBundle(extras), 60000, false ); }
Example 5
Source File: BoundaryEventHeadlessTaskService.java From react-native-boundary with Apache License 2.0 | 5 votes |
@Nullable protected HeadlessJsTaskConfig getTaskConfig(Intent intent) { Bundle extras = intent.getExtras(); return new HeadlessJsTaskConfig( "OnBoundaryEvent", extras != null ? Arguments.fromBundle(extras) : null, 5000, true); }
Example 6
Source File: ReactNativeEventStarter.java From react-native-background-job with MIT License | 5 votes |
@Nullable @Override protected HeadlessJsTaskConfig getTaskConfig(Intent intent) { Log.d(LOG_TAG, "getTaskConfig() called with: intent = [" + intent + "]"); Bundle extras = intent.getExtras(); boolean allowExecutionInForeground = extras.getBoolean("allowExecutionInForeground", false); long timeout = extras.getLong("timeout", 2000); // For task with quick execution period additional check is required ReactNativeHost reactNativeHost = ((ReactApplication) getApplicationContext()).getReactNativeHost(); boolean appInForeground = Utils.isReactNativeAppInForeground(reactNativeHost); if (appInForeground && !allowExecutionInForeground) { return null; } return new HeadlessJsTaskConfig(intent.getStringExtra("jobKey"), Arguments.fromBundle(extras), timeout, allowExecutionInForeground); }
Example 7
Source File: LaunchArgsParser.java From react-native-navigation with MIT License | 5 votes |
/** * 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(); }
Example 8
Source File: HeadlessService.java From react-native-background-geolocation with Apache License 2.0 | 5 votes |
@Override protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) { Bundle extras = intent.getExtras(); if (extras != null) { return new HeadlessJsTaskConfig( TASK_KEY, Arguments.fromBundle(extras), 60000, // timeout for the task true // optional: defines whether or not the task is allowed in foreground. Default is false ); } return null; }
Example 9
Source File: RNDataWedgeIntentsModule.java From react-native-datawedge-intents with MIT License | 4 votes |
@Override public void update(Observable observable, Object data) { Intent intent = (Intent)data; if (intent.hasExtra("v2API")) { Bundle intentBundle = intent.getExtras(); intentBundle.remove("com.symbol.datawedge.decode_data"); // fb converter cannot cope with byte arrays intentBundle.remove("com.motorolasolutions.emdk.datawedge.decode_data"); // fb converter cannot cope with byte arrays WritableMap map = Arguments.fromBundle(intentBundle); sendEvent(this.reactContext, "datawedge_broadcast_intent", map); } String action = intent.getAction(); if (action.equals(ACTION_ENUMERATEDLISET)) { Bundle b = intent.getExtras(); String[] scanner_list = b.getStringArray(KEY_ENUMERATEDSCANNERLIST); WritableArray userFriendlyScanners = new WritableNativeArray(); for (int i = 0; i < scanner_list.length; i++) { userFriendlyScanners.pushString(scanner_list[i]); } try { WritableMap enumeratedScannersObj = new WritableNativeMap(); enumeratedScannersObj.putArray("Scanners", userFriendlyScanners); sendEvent(this.reactContext, "enumerated_scanners", enumeratedScannersObj); } catch (Exception e) { Toast.makeText(this.reactContext, "Error returning scanners", Toast.LENGTH_LONG).show(); e.printStackTrace(); } } else { // Intent from the scanner (barcode has been scanned) String decodedSource = intent.getStringExtra(RECEIVED_SCAN_SOURCE); String decodedData = intent.getStringExtra(RECEIVED_SCAN_DATA); String decodedLabelType = intent.getStringExtra(RECEIVED_SCAN_TYPE); WritableMap scanData = new WritableNativeMap(); scanData.putString("source", decodedSource); scanData.putString("data", decodedData); scanData.putString("labelType", decodedLabelType); sendEvent(this.reactContext, "barcode_scan", scanData); } }