Example usage for com.facebook.react ReactInstanceManager onHostPause

List of usage examples for com.facebook.react ReactInstanceManager onHostPause

Introduction

In this page you can find the example usage for com.facebook.react ReactInstanceManager onHostPause.

Prototype

@ThreadConfined(UI)
public void onHostPause(Activity activity) 

Source Link

Document

Call this from Activity#onPause() .

Usage

From source file:org.jitsi.meet.sdk.JitsiMeetActivityDelegate.java

License:Apache License

/**
 * {@link Activity} lifecycle method which should be called from
 * {@code Activity#onPause} so we can do the required internal processing.
 *
 * @param activity {@code Activity} being paused.
 *///from   w w  w .  ja v  a2 s .co m
public static void onHostPause(Activity activity) {
    ReactInstanceManager reactInstanceManager = ReactInstanceManagerHolder.getReactInstanceManager();

    if (reactInstanceManager != null) {
        // Try to avoid a crash because some devices trip on this assert:
        // https://github.com/facebook/react-native/blob/df4e67fe75d781d1eb264128cadf079989542755/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java#L512
        // Why this happens is a mystery wrapped in an enigma.
        ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
        if (activity == reactContext.getCurrentActivity()) {
            reactInstanceManager.onHostPause(activity);
        }
    }
}