当前位置: 首页>>代码示例>>Java>>正文


Java ReactNativeHost类代码示例

本文整理汇总了Java中com.facebook.react.ReactNativeHost的典型用法代码示例。如果您正苦于以下问题:Java ReactNativeHost类的具体用法?Java ReactNativeHost怎么用?Java ReactNativeHost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ReactNativeHost类属于com.facebook.react包,在下文中一共展示了ReactNativeHost类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: callJavaScript

import com.facebook.react.ReactNativeHost; //导入依赖的package包/类
@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!");
            catalystInstance.callFunction("JavaScriptVisibleToJava", "alert", params);
        }
    }
}
 
开发者ID:petterh,项目名称:react-native-android-activity,代码行数:18,代码来源:ActivityStarterModule.java

示例2: RNThreadModule

import com.facebook.react.ReactNativeHost; //导入依赖的package包/类
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);
}
 
开发者ID:joltup,项目名称:react-native-threads,代码行数:9,代码来源:RNThreadModule.java

示例3: onCreate

import com.facebook.react.ReactNativeHost; //导入依赖的package包/类
/**
 * Demonstrates how to add a custom option to the dev menu.
 * https://stackoverflow.com/a/44882371/3968276
 */
@Override
protected void onCreate(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() {
            Toast.makeText(MainActivity.this, "Hello from custom dev option", Toast.LENGTH_SHORT).show();
        }
    });
}
 
开发者ID:petterh,项目名称:react-native-android-activity,代码行数:19,代码来源:MainActivity.java

示例4: getTaskConfig

import com.facebook.react.ReactNativeHost; //导入依赖的package包/类
@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);
}
 
开发者ID:vikeri,项目名称:react-native-background-job,代码行数:16,代码来源:ReactNativeEventStarter.java

示例5: isReactNativeAppInForeground

import com.facebook.react.ReactNativeHost; //导入依赖的package包/类
/** 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;
}
 
开发者ID:vikeri,项目名称:react-native-background-job,代码行数:10,代码来源:Utils.java

示例6: getReactNativeHost

import com.facebook.react.ReactNativeHost; //导入依赖的package包/类
@Override
public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
}
 
开发者ID:hiteshsahu,项目名称:FingerPrint-Authentication-With-React-Native-Android,代码行数:5,代码来源:MainApplication.java

示例7: getReactNativeHost

import com.facebook.react.ReactNativeHost; //导入依赖的package包/类
@Override
public ReactNativeHost getReactNativeHost() {
  return mReactNativeHost;
}
 
开发者ID:miguelespinoza,项目名称:react-native-nearby,代码行数:5,代码来源:MainApplication.java

示例8: RNThreadPackage

import com.facebook.react.ReactNativeHost; //导入依赖的package包/类
public RNThreadPackage(ReactNativeHost reactNativeHost, ReactPackage... additionalThreadPackages) {
    this.reactNativeHost = reactNativeHost;
    this.additionalThreadPackages = additionalThreadPackages;
}
 
开发者ID:joltup,项目名称:react-native-threads,代码行数:5,代码来源:RNThreadPackage.java


注:本文中的com.facebook.react.ReactNativeHost类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。