{% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

ActivityLifecycleMonitorRegistry

class ActivityLifecycleMonitorRegistry


An exposed registry instance to make it easy for callers to find the lifecycle monitor for their application.

Summary

Public constructors

Public functions

java-static ActivityLifecycleMonitor!

Returns the ActivityLifecycleMonitor.

java-static Unit

Stores a lifecycle monitor in the registry.

Public constructors

ActivityLifecycleMonitorRegistry

ActivityLifecycleMonitorRegistry()

Public functions

getInstance

java-static fun getInstance(): ActivityLifecycleMonitor!

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: java.lang.IllegalStateException

if no monitor has been registered.

registerInstance

java-static fun registerInstance(monitor: ActivityLifecycleMonitor!): Unit

Stores a lifecycle monitor in the registry.

This is a global registry - so be aware of the impact of calling this method!

Parameters
monitor: ActivityLifecycleMonitor!

the monitor for this application. Null deregisters any existing monitor.