public abstract class ReactInstanceManager
extends java.lang.Object
CatalystInstance. It expose a way to configure
catalyst instance using ReactPackage and keeps track of the lifecycle of that
instance. It also sets up connection between the instance and developers support functionality
of the framework.
An instance of this manager is required to start JS application in ReactRootView (see
ReactRootView.startReactApplication(com.facebook.react.ReactInstanceManager, java.lang.String) for more info).
The lifecycle of the instance of ReactInstanceManager should be bound to the activity
that owns the ReactRootView that is used to render react application using this
instance manager (see ReactRootView.startReactApplication(com.facebook.react.ReactInstanceManager, java.lang.String)). It's required to pass
owning activity's lifecycle events to the instance manager (see onPause(),
onDestroy() and onResume(android.app.Activity, com.facebook.react.modules.core.DefaultHardwareBackBtnHandler)).
Ideally, this would be an interface, but because of the API used by earlier versions, it has to
have a static method, and so cannot (in Java < 8), be one.| Modifier and Type | Class and Description |
|---|---|
static class |
ReactInstanceManager.Builder
Builder class for
ReactInstanceManagerImpl |
| Constructor and Description |
|---|
ReactInstanceManager() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
attachMeasuredRootView(ReactRootView rootView)
Attach given to a catalyst instance manager and start JS application using
JS module provided by
ReactRootView.getJSModuleName(). |
static ReactInstanceManager.Builder |
builder()
Creates a builder that is capable of creating an instance of
ReactInstanceManagerImpl. |
abstract java.util.List<ViewManager> |
createAllViewManagers(ReactApplicationContext catalystApplicationContext)
Uses configured
ReactPackage instances to create all view managers |
abstract void |
createReactContextInBackground()
Trigger react context initialization asynchronously in a background async task.
|
abstract void |
detachRootView(ReactRootView rootView)
Detach given from current catalyst instance.
|
abstract ReactContext |
getCurrentReactContext() |
abstract DevSupportManager |
getDevSupportManager() |
abstract java.lang.String |
getSourceUrl()
Get the URL where the last bundle was loaded from.
|
abstract boolean |
hasStartedCreatingInitialContext() |
abstract void |
onActivityResult(int requestCode,
int resultCode,
android.content.Intent data) |
abstract void |
onBackPressed()
This method will give JS the opportunity to consume the back button event.
|
abstract void |
onDestroy() |
abstract void |
onPause() |
abstract void |
onResume(android.app.Activity activity,
DefaultHardwareBackBtnHandler defaultBackButtonImpl)
Use this method when the activity resumes to enable invoking the back button directly from JS.
|
abstract void |
showDevOptionsDialog() |
public abstract DevSupportManager getDevSupportManager()
public abstract void createReactContextInBackground()
ReactRootView is available and measured. This should only be called the first time the
application is set up, which is enforced to keep developers from accidentally creating their
application multiple times without realizing it.
Called from UI thread.public abstract boolean hasStartedCreatingInitialContext()
public abstract void onBackPressed()
public abstract void onPause()
public abstract void onResume(android.app.Activity activity,
DefaultHardwareBackBtnHandler defaultBackButtonImpl)
ReactInstanceManager, so that once this instance receive onDestroy() event it will
clear the reference to that defaultBackButtonImpl.defaultBackButtonImpl - a DefaultHardwareBackBtnHandler from an Activity that owns
this instance of ReactInstanceManager.public abstract void onDestroy()
public abstract void onActivityResult(int requestCode,
int resultCode,
android.content.Intent data)
public abstract void showDevOptionsDialog()
public abstract java.lang.String getSourceUrl()
public abstract void attachMeasuredRootView(ReactRootView rootView)
ReactRootView.getJSModuleName(). If the react context is currently
being (re)-created, or if react context has not been created yet, the JS application associated
with the provided root view will be started asynchronously, i.e this method won't block.
This view will then be tracked by this manager and in case of catalyst instance restart it will
be re-attached.public abstract void detachRootView(ReactRootView rootView)
public abstract java.util.List<ViewManager> createAllViewManagers(ReactApplicationContext catalystApplicationContext)
ReactPackage instances to create all view managers@Nullable public abstract ReactContext getCurrentReactContext()
public static ReactInstanceManager.Builder builder()
ReactInstanceManagerImpl.