android: add ability to get the current Activity running RN
This helper method gets the current Activity attached to React Native (via the ReactContext). This is useful for modules which need access to it, without being actual React Native modules.
This commit is contained in:
parent
f71ec55170
commit
0bc369afb4
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.jitsi.meet.sdk;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
|
@ -120,6 +121,18 @@ class ReactInstanceManagerHolder {
|
|||
? reactContext.getNativeModule(nativeModuleClass) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current {@link Activity} linked to React Native.
|
||||
*
|
||||
* @return An activity attached to React Native.
|
||||
*/
|
||||
static Activity getCurrentActivity() {
|
||||
ReactContext reactContext
|
||||
= reactInstanceManager != null
|
||||
? reactInstanceManager.getCurrentReactContext() : null;
|
||||
return reactContext != null ? reactContext.getCurrentActivity() : null;
|
||||
}
|
||||
|
||||
static ReactInstanceManager getReactInstanceManager() {
|
||||
return reactInstanceManager;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue