本文整理匯總了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;
}