本文整理汇总了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);
}
}
}
示例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);
}
示例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();
}
});
}
示例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);
}
示例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;
}
示例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;
}
示例8: RNThreadPackage
import com.facebook.react.ReactNativeHost; //导入依赖的package包/类
public RNThreadPackage(ReactNativeHost reactNativeHost, ReactPackage... additionalThreadPackages) {
this.reactNativeHost = reactNativeHost;
this.additionalThreadPackages = additionalThreadPackages;
}