public abstract class ReactContextBaseJavaModule extends BaseJavaModule
ReactContext
instance.NativeModule.NativeMethod
METHOD_TYPE_ASYNC, METHOD_TYPE_PROMISE, METHOD_TYPE_SYNC
Constructor and Description |
---|
ReactContextBaseJavaModule() |
ReactContextBaseJavaModule(ReactApplicationContext reactContext) |
Modifier and Type | Method and Description |
---|---|
protected android.app.Activity |
getCurrentActivity()
Get the activity to which this context is currently attached, or
null if not attached. |
protected ReactApplicationContext |
getReactApplicationContext()
Subclasses can use this method to access catalyst context passed as a constructor.
|
protected ReactApplicationContext |
getReactApplicationContextIfActiveOrWarn()
Subclasses can use this method to access catalyst context passed as a constructor.
|
canOverrideExistingModule, getConstants, hasConstants, initialize, invalidate, onCatalystInstanceDestroy
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName
public ReactContextBaseJavaModule()
public ReactContextBaseJavaModule(ReactApplicationContext reactContext)
protected final ReactApplicationContext getReactApplicationContext()
protected final ReactApplicationContext getReactApplicationContextIfActiveOrWarn()
This can return null at any time, but especially during teardown methods it's possible/likely.
Threading implications have not been analyzed fully yet, so assume this method is not thread-safe.
protected final android.app.Activity getCurrentActivity()
null
if not attached.
DO NOT HOLD LONG-LIVED REFERENCES TO THE OBJECT RETURNED BY THIS METHOD, AS THIS WILL CAUSE MEMORY LEAKS.
For example, never store the value returned by this method in a member variable. Instead,
call this method whenever you actually need the Activity and make sure to check for null
.