List of usage examples for com.facebook.react ReactInstanceManager builder
public static ReactInstanceManagerBuilder builder()
From source file:com.lighters.demos.reactnative.ToastRnActivity.java
License:Apache License
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mReactRootView = new ReactRootView(this); mReactInstanceManager = ReactInstanceManager.builder().setApplication(getApplication()) .setBundleAssetName("index.android.bundle").setJSMainModuleName("index.android") .addPackage(new MainReactPackage()).addPackage(new ToastExampleReactPackage()) .setUseDeveloperSupport(BuildConfig.DEBUG) //.setUseDeveloperSupport(false) .setInitialLifecycleState(LifecycleState.RESUMED) //.setUseOldBridge(true) // uncomment this line if your app crashes .build();// w w w . j a va 2 s.c o m mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", null); setContentView(mReactRootView); }
From source file:com.publicradionative.MainActivity.java
License:Apache License
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mReactRootView = new ReactRootView(this); mReactInstanceManager = ReactInstanceManager.builder().setApplication(getApplication()) .setBundleAssetName("index.android.bundle").setJSMainModuleName("index.android") .addPackage(new MainReactPackage()).addPackage(new VectorIconsPackage()) .addPackage(new ProjectModulesPackage(this)).setUseDeveloperSupport(BuildConfig.DEBUG) .setInitialLifecycleState(LifecycleState.RESUMED).build(); mReactRootView.startReactApplication(mReactInstanceManager, "PublicRadioNative", null); setContentView(mReactRootView);/*from www. j a v a 2s . co m*/ }
From source file:com.socialdisasters.other.MainActivity.java
License:Open Source License
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mReactRootView = new ReactRootView(this); mReactInstanceManager = ReactInstanceManager.builder().setApplication(getApplication()) .setBundleAssetName("index.android.bundle").setJSMainModuleName("index.android") .addPackage(new MainReactPackage()).setUseDeveloperSupport(BuildConfig.DEBUG) .setInitialLifecycleState(LifecycleState.RESUMED).build(); mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", null); setContentView(mReactRootView);//from w w w . java 2s . c om }
From source file:org.jitsi.meet.sdk.ReactInstanceManagerHolder.java
License:Apache License
/** * Internal method to initialize the React Native instance manager. We * create a single instance in order to load the JavaScript bundle a single * time. All {@code ReactRootView} instances will be tied to the one and * only {@code ReactInstanceManager}./* w ww . j av a 2 s. co m*/ * * @param activity {@code Activity} current running Activity. */ static void initReactInstanceManager(Activity activity) { if (reactInstanceManager != null) { return; } SoLoader.init(activity, /* native exopackage */ false); List<ReactPackage> packages = new ArrayList<>(Arrays.asList( new com.BV.LinearGradient.LinearGradientPackage(), new com.calendarevents.CalendarEventsPackage(), new com.corbt.keepawake.KCKeepAwakePackage(), new com.facebook.react.shell.MainReactPackage(), new com.horcrux.svg.SvgPackage(), new com.ocetnik.timer.BackgroundTimerPackage(), new com.reactnativecommunity.asyncstorage.AsyncStoragePackage(), new com.reactnativecommunity.netinfo.NetInfoPackage(), new com.reactnativecommunity.webview.RNCWebViewPackage(), new com.rnimmersive.RNImmersivePackage(), new com.zmxv.RNSound.RNSoundPackage(), new ReactPackageAdapter() { @Override public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { return ReactInstanceManagerHolder.createNativeModules(reactContext); } @Override public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { return ReactInstanceManagerHolder.createViewManagers(reactContext); } })); try { Class<?> googlePackageClass = Class.forName("co.apptailor.googlesignin.RNGoogleSigninPackage"); Constructor constructor = googlePackageClass.getConstructor(); packages.add((ReactPackage) constructor.newInstance()); } catch (Exception e) { // Ignore any error, the module is not compiled when LIBRE_BUILD is enabled. } // Keep on using JSC, the jury is out on Hermes. JSCExecutorFactory jsFactory = new JSCExecutorFactory("", ""); reactInstanceManager = ReactInstanceManager.builder().setApplication(activity.getApplication()) .setCurrentActivity(activity).setBundleAssetName("index.android.bundle") .setJSMainModulePath("index.android").setJavaScriptExecutorFactory(jsFactory).addPackages(packages) .setUseDeveloperSupport(BuildConfig.DEBUG).setInitialLifecycleState(LifecycleState.RESUMED).build(); // Disable delta updates on Android, they have caused trouble. DevInternalSettings devSettings = (DevInternalSettings) reactInstanceManager.getDevSupportManager() .getDevSettings(); if (devSettings != null) { devSettings.setBundleDeltasEnabled(false); } // Register our uncaught exception handler. JitsiMeetUncaughtExceptionHandler.register(); }