# ApplicationLifecycleMonitorRegistry

# ApplicationLifecycleMonitorRegistry

Artifact:[androidx.test:monitor](https://developer.android.com/jetpack/androidx/releases/test)  
[View Source](https://cs.android.com/search?q=file:androidx/test/runner/lifecycle/ApplicationLifecycleMonitorRegistry.java+class:androidx.test.runner.lifecycle.ApplicationLifecycleMonitorRegistry)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/test/runner/lifecycle/ApplicationLifecycleMonitorRegistry "View this page in Java")

<br />

```
class ApplicationLifecycleMonitorRegistry
```

<br />

*** ** * ** ***

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

## Summary

|                                                                   ### Public functions                                                                    |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[ApplicationLifecycleMonitor](https://developer.android.com/reference/kotlin/androidx/test/runner/lifecycle/ApplicationLifecycleMonitor)`!` | [getInstance](https://developer.android.com/reference/kotlin/androidx/test/runner/lifecycle/ApplicationLifecycleMonitorRegistry#getInstance())`()` Returns the ActivityLifecycleMonitor.                                                                                                                                                                                                                               |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                               | [registerInstance](https://developer.android.com/reference/kotlin/androidx/test/runner/lifecycle/ApplicationLifecycleMonitorRegistry#registerInstance(androidx.test.runner.lifecycle.ApplicationLifecycleMonitor))`(monitor: `[ApplicationLifecycleMonitor](https://developer.android.com/reference/kotlin/androidx/test/runner/lifecycle/ApplicationLifecycleMonitor)`!)` Stores a lifecycle monitor in the registry. |

## Public functions

### getInstance

```
java-static fun getInstance(): ApplicationLifecycleMonitor!
```

Returns the ActivityLifecycleMonitor.

This monitor is not guaranteed to be present under all instrumentations.  

|                                                                   Returns                                                                   |
|---------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [ApplicationLifecycleMonitor](https://developer.android.com/reference/kotlin/androidx/test/runner/lifecycle/ApplicationLifecycleMonitor)`!` | ActivityLifecycleMonitor the monitor for this application. |

|                                                     Throws                                                      |
|-----------------------------------------------------------------------------------------------------------------|------------------------------------|
| [java.lang.IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if no monitor has been registered. |

### registerInstance

```
java-static fun registerInstance(monitor: ApplicationLifecycleMonitor!): 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: `[ApplicationLifecycleMonitor](https://developer.android.com/reference/kotlin/androidx/test/runner/lifecycle/ApplicationLifecycleMonitor)`!` | the monitor for this application. Null deregisters any existing monitor. |