@ReactMethod public void initialize() { ReactApplication application = (ReactApplication)getReactApplicationContext() .getCurrentActivity() .getApplication(); DevSupportManager devSupportManager = application .getReactNativeHost() .getReactInstanceManager() .getDevSupportManager(); devSupportManager.addCustomDevOption("Log AsyncStorage", new DevOptionHandler() { @Override public void onOptionSelected() { getReactApplicationContext() .getJSModule(RCTNativeAppEventEmitter.class) .emit("LogAsyncStorage", null); } }); }
private ReactInstanceManager resolveInstanceManager() throws NoSuchFieldException, IllegalAccessException { ReactInstanceManager instanceManager = getReactInstanceManager(); if (instanceManager != null) { return instanceManager; } final Activity currentActivity = getCurrentActivity(); if (currentActivity == null) { return null; } ReactApplication reactApplication = (ReactApplication) currentActivity.getApplication(); instanceManager = reactApplication.getReactNativeHost().getReactInstanceManager(); return instanceManager; }
public DevSettingsModule(ReactApplicationContext context) { super(context); reactContext = context; rnHost = ((ReactApplication) context.getApplicationContext()) .getReactNativeHost(); instanceManager = rnHost.getReactInstanceManager(); useDeveloperSupport = rnHost.getUseDeveloperSupport(); if (useDeveloperSupport) { devManager = ((DevSupportManagerImpl) instanceManager.getDevSupportManager()); } }
@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); }
public RNSentryModule(ReactApplicationContext reactContext, ReactApplication reactApplication) { super(reactContext); this.reactContext = reactContext; this.reactApplication = reactApplication; RNSentryModule.extra = new WritableNativeMap(); RNSentryModule.packageInfo = getPackageInfo(reactContext); }
/** * Pre-load {@link ReactRootView} to local {@link Map}, you may want to * load it in previous activity. */ public static void init(Activity activity, ReactInfo reactInfo) { if (CACHE_VIEW_MAP.get(reactInfo.getMainComponentName()) != null) { return; } ReactRootView rootView = new ReactRootView(new MutableContextWrapper(activity)); rootView.startReactApplication( ((ReactApplication) activity.getApplication()).getReactNativeHost().getReactInstanceManager(), reactInfo.getMainComponentName(), reactInfo.getLaunchOptions()); CACHE_VIEW_MAP.put(reactInfo.getMainComponentName(), rootView); }
protected void sendTokenToJS() { final ReactInstanceManager instanceManager = ((ReactApplication) mAppContext).getReactNativeHost().getReactInstanceManager(); final ReactContext reactContext = instanceManager.getCurrentReactContext(); // Note: Cannot assume react-context exists cause this is an async dispatched service. if (reactContext != null && reactContext.hasActiveCatalystInstance()) { reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(TOKEN_RECEIVED_EVENT_NAME, sToken); } }
private ReactInstanceManager resolveInstanceManager() throws NoSuchFieldException, IllegalAccessException { ReactInstanceManager instanceManager; final Activity currentActivity = getCurrentActivity(); if (currentActivity == null) { return null; } ReactApplication reactApplication = (ReactApplication) currentActivity.getApplication(); instanceManager = reactApplication.getReactNativeHost().getReactInstanceManager(); return instanceManager; }
private ReactInstanceManager getReactInstanceManager() { ReactApplication reactApplication = (ReactApplication)getCurrentActivity().getApplication(); return reactApplication.getReactNativeHost().getReactInstanceManager(); }
ReactNativeEventStarter(@NonNull Context context) { this.context = context; reactNativeHost = ((ReactApplication) context.getApplicationContext()).getReactNativeHost(); }
public RNSentryPackage(ReactApplication reactApplication) { this.reactApplication = reactApplication; }
public ReactApplication getReactApplication() { return reactApplication; }
protected GcmToken(Context appContext) { if (!(appContext instanceof ReactApplication)) { throw new IllegalStateException("Application instance isn't a react-application"); } mAppContext = appContext; }
/** * Get the {@link ReactNativeHost} used by this app. By default, assumes * {@link Activity#getApplication()} is an instance of {@link ReactApplication} and calls * {@link ReactApplication#getReactNativeHost()}. Override this method if your application class * does not implement {@code ReactApplication} or you simply have a different mechanism for * storing a {@code ReactNativeHost}, e.g. as a static field somewhere. */ protected ReactNativeHost getReactNativeHost() { return ((ReactApplication) getActivity().getApplication()).getReactNativeHost(); }
/** * Get the {@link ReactNativeHost} used by this app. By default, assumes {@link #getApplication()} * is an instance of {@link ReactApplication} and calls * {@link ReactApplication#getReactNativeHost()}. Override this method if your application class * does not implement {@code ReactApplication} or you simply have a different mechanism for * storing a {@code ReactNativeHost}, e.g. as a static field somewhere. */ protected ReactNativeHost getReactNativeHost() { return ((ReactApplication) getApplication()).getReactNativeHost(); }