{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}
public final class ActivityLifecycleMonitorRegistry
An exposed registry instance to make it easy for callers to find the lifecycle monitor for their application.
Public methods |
|
|---|---|
static @NonNull ActivityLifecycleMonitor |
Returns the ActivityLifecycleMonitor. |
static @NonNull void |
registerInstance(@NonNull ActivityLifecycleMonitor monitor)Stores a lifecycle monitor in the registry. |
@NonNull
public static ActivityLifecycleMonitor getInstance()
Returns the ActivityLifecycleMonitor.
This monitor is not guaranteed to be present under all instrumentations.
| Returns | |
|---|---|
ActivityLifecycleMonitor |
ActivityLifecycleMonitor the monitor for this application. |
| Throws | |
|---|---|
java.lang.IllegalStateException |
if no monitor has been registered. |
@NonNull
public static void registerInstance(@NonNull ActivityLifecycleMonitor monitor)
Stores a lifecycle monitor in the registry.
This is a global registry - so be aware of the impact of calling this method!
| Parameters | |
|---|---|
@NonNull ActivityLifecycleMonitor monitor |
the monitor for this application. Null deregisters any existing monitor. |