com.facebook.react.ReactNativeHost Java Examples
The following examples show how to use
com.facebook.react.ReactNativeHost.
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: MainActivity.java From react-native-android-activity with MIT License | 7 votes |
/** * Demonstrates how to add a custom option to the dev menu. * https://stackoverflow.com/a/44882371/3968276 * This only works from the debug build with dev options enabled. */ @Override @CallSuper protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); MainApplication application = (MainApplication) getApplication(); ReactNativeHost reactNativeHost = application.getReactNativeHost(); ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager(); DevSupportManager devSupportManager = reactInstanceManager.getDevSupportManager(); devSupportManager.addCustomDevOption("Custom dev option", new DevOptionHandler() { @Override public void onOptionSelected() { if (NotificationManagerCompat.from(MainActivity.this).areNotificationsEnabled()) { Toast.makeText(MainActivity.this, CUSTOM_DEV_OPTION_MESSAGE, Toast.LENGTH_LONG).show(); } else { AlertDialog dialog = new AlertDialog.Builder(MainActivity.this).create(); dialog.setTitle("Dev option"); dialog.setMessage(CUSTOM_DEV_OPTION_MESSAGE); dialog.show(); } } }); }
Example #2
Source File: ActivityStarterModule.java From react-native-android-activity with MIT License | 6 votes |
@ReactMethod void callJavaScript() { Activity activity = getCurrentActivity(); if (activity != null) { MainApplication application = (MainApplication) activity.getApplication(); ReactNativeHost reactNativeHost = application.getReactNativeHost(); ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager(); ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); if (reactContext != null) { CatalystInstance catalystInstance = reactContext.getCatalystInstance(); WritableNativeArray params = new WritableNativeArray(); params.pushString("Hello, JavaScript!"); // AFAIK, this approach to communicate from Java to JavaScript is officially undocumented. // Use at own risk; prefer events. // Note: Here we call 'alert', which shows UI. If this is done from an activity that // doesn't forward lifecycle events to React Native, it wouldn't work. catalystInstance.callFunction("JavaScriptVisibleToJava", "alert", params); } } }
Example #3
Source File: RNThreadModule.java From react-native-threads with MIT License | 5 votes |
public RNThreadModule(final ReactApplicationContext reactContext, ReactNativeHost reactNativehost, ReactPackage additionalThreadPackages[]) { super(reactContext); this.reactApplicationContext = reactContext; threads = new HashMap<>(); this.reactNativeHost = reactNativehost; this.additionalThreadPackages = additionalThreadPackages; reactContext.addLifecycleEventListener(this); }
Example #4
Source File: ScriptLoadUtil.java From react-native-multibundler with The Unlicense | 5 votes |
@Nullable public static CatalystInstance getCatalystInstance(ReactNativeHost host) { ReactInstanceManager manager = host.getReactInstanceManager(); if (manager == null) { Log.e(TAG,"manager is null!!"); return null; } ReactContext context = manager.getCurrentReactContext(); if (context == null) { Log.e(TAG,"context is null!!"); return null; } return context.getCatalystInstance(); }
Example #5
Source File: Utils.java From react-native-background-job with MIT License | 5 votes |
/** Check whether on not the React Native application is in foreground. */ public static boolean isReactNativeAppInForeground(@NonNull ReactNativeHost reactNativeHost) { if (!reactNativeHost.hasInstance()) { // If the app was force-stopped the instace will be destroyed. The instance can't be created from a background thread. return false; } ReactContext reactContext = reactNativeHost.getReactInstanceManager().getCurrentReactContext(); return reactContext != null && reactContext.getLifecycleState() == LifecycleState.RESUMED; }
Example #6
Source File: MainApplication.java From 9-project-layout with Apache License 2.0 | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #7
Source File: MainApplication.java From react-native-photo-editor with Apache License 2.0 | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #8
Source File: MainApplication.java From react-native-selection-menu with Apache License 2.0 | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #9
Source File: MainApplication.java From react-native-secure-storage with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #10
Source File: MainApplication.java From react-native-doc-viewer with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #11
Source File: MainApplication.java From react-native-x5 with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #12
Source File: MainApplication.java From react-native-audio-streaming with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #13
Source File: MainApplication.java From react-native-app-auth with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #14
Source File: MainApplication.java From react-native-get-sms-android with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #15
Source File: MainApplication.java From react-native-android-wear-demo with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #16
Source File: MainApplication.java From native-navigation with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #17
Source File: MainApplication.java From react-native-device-info with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #18
Source File: MainApplication.java From react-native-workers with BSD 2-Clause "Simplified" License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #19
Source File: MainApplication.java From react-native-directed-scrollview with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #20
Source File: MainApplication.java From react-native-GPay with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #21
Source File: MainApplication.java From react-native-call-log with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #22
Source File: MainApplication.java From react-native-google-fitness with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #23
Source File: MainApplication.java From react-native-rtmpview with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #24
Source File: MainApplication.java From react-native-speech with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #25
Source File: MainApplication.java From react-native-android-fragment with Apache License 2.0 | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #26
Source File: MainApplication.java From react-native-share-extension with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #27
Source File: MainApplication.java From ReactNative-AndAndroid with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #28
Source File: MainApplication.java From react-native-prompt-android with MIT License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #29
Source File: MainApplication.java From react-native-square-reader-sdk with Apache License 2.0 | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }
Example #30
Source File: MainApplication.java From react-native-secure-key-store with ISC License | 4 votes |
@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }