List of usage examples for com.facebook.react.bridge ReactContext getCurrentActivity
public @Nullable Activity getCurrentActivity()
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 . j av a2s. c o 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); } } }
From source file:org.jitsi.meet.sdk.ReactInstanceManagerHolder.java
License:Apache License
/** * Gets the current {@link Activity} linked to React Native. * * @return An activity attached to React Native. *//*from w w w .j a v a 2 s. c om*/ static Activity getCurrentActivity() { ReactContext reactContext = reactInstanceManager != null ? reactInstanceManager.getCurrentReactContext() : null; return reactContext != null ? reactContext.getCurrentActivity() : null; }