# ActivityLifecycles

Summary:[Methods](https://developer.android.com/reference/android/support/test/espresso/util/ActivityLifecycles#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/test/espresso/util/ActivityLifecycles#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/test/espresso/util/ActivityLifecycles#)  

# ActivityLifecycles

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public

final

class
ActivityLifecycles
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object.html)`


``


`

|---|-------------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||
| ↳ | android.support.test.espresso.util.ActivityLifecycles |

<br />

*** ** * ** ***

Helper methods to understand ActivityLifecycle of the app.

## Summary

|                                                                                                                                                                                                                                                ### Public methods                                                                                                                                                                                                                                                 ||
|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static boolean` | ` `[hasForegroundActivities](https://developer.android.com/reference/android/support/test/espresso/util/ActivityLifecycles#hasForegroundActivities(android.support.test.runner.lifecycle.ActivityLifecycleMonitor))`(`[ActivityLifecycleMonitor](https://developer.android.com/reference/android/support/test/runner/lifecycle/ActivityLifecycleMonitor)` monitor) ` Indicates whether or not an Activity in our app is currently in the foreground.                                           |
| ` static boolean` | ` `[hasTransitioningActivities](https://developer.android.com/reference/android/support/test/espresso/util/ActivityLifecycles#hasTransitioningActivities(android.support.test.runner.lifecycle.ActivityLifecycleMonitor))`(`[ActivityLifecycleMonitor](https://developer.android.com/reference/android/support/test/runner/lifecycle/ActivityLifecycleMonitor)` monitor) ` Indicates whether or not an Activity, not in the foreground, exists in our app within the "Visible Lifetime" state. |
| ` static boolean` | ` `[hasVisibleActivities](https://developer.android.com/reference/android/support/test/espresso/util/ActivityLifecycles#hasVisibleActivities(android.support.test.runner.lifecycle.ActivityLifecycleMonitor))`(`[ActivityLifecycleMonitor](https://developer.android.com/reference/android/support/test/runner/lifecycle/ActivityLifecycleMonitor)` monitor) ` Indicates whether or not an Activity exists in our app within the "Visible Lifetime" state.                                     |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/espresso/util/ActivityLifecycles#)From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object.html)` ` |-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                                | | ` boolean`                                                                          | ` equals(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                             | ` finalize() `                                                                             | | ` final `[Class](https://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                             | | ` int`                                                                              | ` hashCode() `                                                                             | | ` final void`                                                                       | ` notify() `                                                                               | | ` final void`                                                                       | ` notifyAll() `                                                                            | | ` `[String](https://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                             | | ` final void`                                                                       | ` wait(long arg0, int arg1) `                                                              | | ` final void`                                                                       | ` wait(long arg0) `                                                                        | | ` final void`                                                                       | ` wait() `                                                                                 | ||

## Public methods

### hasForegroundActivities

```
boolean hasForegroundActivities (ActivityLifecycleMonitor monitor)
```

Indicates whether or not an Activity in our app is currently in the foreground.

The "Foreground lifetime" of an activity occurs after a call to onResume and before a call to onPause.

During this time, the activity is in front of all other activities and is currently receiving user input.

<br />

|                                     Parameters                                     ||
|-----------|-------------------------------------------------------------------------|
| `monitor` | `ActivityLifecycleMonitor`: the ActivityLifecycleMonitor to use. <br /> |

|                                Returns                                ||
|-----------|------------------------------------------------------------|
| `boolean` | true if an activity exists in the foreground state. <br /> |

### hasTransitioningActivities

```
boolean hasTransitioningActivities (ActivityLifecycleMonitor monitor)
```

Indicates whether or not an Activity, not in the foreground, exists in our app within the "Visible Lifetime" state.

The "Visible Lifetime" is defined as an activity where the onStart() method has been called but where the onStop() method has not been called.

During this time, the Activity may be visible to the user, and it may be receiving input from the user. This time is a superset of the "Foreground lifetime" of the activity.

It may be the case that an application has activities in the "visible lifetime" but none in the "Foreground lifetime." It may be the case that without user input an activity will shortly transition into the "Foreground lifetime" in this state, however it also may not transition without further user interaction.

<br />

|                                    Parameters                                     ||
|-----------|------------------------------------------------------------------------|
| `monitor` | `ActivityLifecycleMonitor`: the ActivityLifecycleMonitor to use <br /> |

|                                  Returns                                  ||
|-----------|----------------------------------------------------------------|
| `boolean` | true if any activity exists with a transitioning stage. <br /> |

### hasVisibleActivities

```
boolean hasVisibleActivities (ActivityLifecycleMonitor monitor)
```

Indicates whether or not an Activity exists in our app within the "Visible Lifetime" state.

The "Visible Lifetime" is defined as an activity where the onStart() method has been called but where the onStop() method has not been called.

During this time, the Activity may be visible to the user, and it may be receiving input from the user. This time is a superset of the "Foreground lifetime" of the activity.

It may be the case that an application has activities in the "visible lifetime" but none in the "Foreground lifetime." It may be the case that without user input an activity will shortly transition into the "Foreground lifetime" in this state, however it also may not transition without further user interaction.

<br />

|                                    Parameters                                     ||
|-----------|------------------------------------------------------------------------|
| `monitor` | `ActivityLifecycleMonitor`: the ActivityLifecycleMonitor to use <br /> |

|                                    Returns                                     ||
|-----------|---------------------------------------------------------------------|
| `boolean` | true if any activity exists within it's foreground lifetime. <br /> |

-

  ## Classes

  - [ActivityLifecycles](https://developer.android.com/reference/android/support/test/espresso/util/ActivityLifecycles)
  - [EspressoOptional](https://developer.android.com/reference/android/support/test/espresso/util/EspressoOptional)
  - [HumanReadables](https://developer.android.com/reference/android/support/test/espresso/util/HumanReadables)
  - [TreeIterables](https://developer.android.com/reference/android/support/test/espresso/util/TreeIterables)
  - [TreeIterables.ViewAndDistance](https://developer.android.com/reference/android/support/test/espresso/util/TreeIterables.ViewAndDistance)