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.
Parameters
monitor
ActivityLifecycleMonitor: the ActivityLifecycleMonitor to use
Returns
boolean
true if any activity exists with a transitioning stage.
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.
Parameters
monitor
ActivityLifecycleMonitor: the ActivityLifecycleMonitor to use
Returns
boolean
true if any activity exists within it's foreground lifetime.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ActivityLifecycles\n\nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \\| [\\[Expand All\\]](#) \n\nActivityLifecycles\n==================\n\n| This package is part of the Android [support library](/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](/jetpack/androidx) which is part of [Jetpack](/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class\n| mappings](/jetpack/androidx/migrate/class-mappings).\n\n\n`\npublic\n\nfinal\n\nclass\nActivityLifecycles\n`\n\n\n`\n\nextends `[Object](https://developer.android.com/reference/java/lang/Object.html)`\n\n\n`\n\n`\n\n\n`\n\n|---|-------------------------------------------------------|\n| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||\n| ↳ | android.support.test.espresso.util.ActivityLifecycles |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nHelper methods to understand ActivityLifecycle of the app.\n\nSummary\n-------\n\n| ### Public methods ||\n|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` static boolean` | ` `[hasForegroundActivities](/reference/android/support/test/espresso/util/ActivityLifecycles#hasForegroundActivities(android.support.test.runner.lifecycle.ActivityLifecycleMonitor))`(`[ActivityLifecycleMonitor](/reference/android/support/test/runner/lifecycle/ActivityLifecycleMonitor)` monitor) ` Indicates whether or not an Activity in our app is currently in the foreground. |\n| ` static boolean` | ` `[hasTransitioningActivities](/reference/android/support/test/espresso/util/ActivityLifecycles#hasTransitioningActivities(android.support.test.runner.lifecycle.ActivityLifecycleMonitor))`(`[ActivityLifecycleMonitor](/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. |\n| ` static boolean` | ` `[hasVisibleActivities](/reference/android/support/test/espresso/util/ActivityLifecycles#hasVisibleActivities(android.support.test.runner.lifecycle.ActivityLifecycleMonitor))`(`[ActivityLifecycleMonitor](/reference/android/support/test/runner/lifecycle/ActivityLifecycleMonitor)` monitor) ` Indicates whether or not an Activity exists in our app within the \"Visible Lifetime\" state. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| 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)`\u003c?\u003e` | ` 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() ` | ||\n\nPublic methods\n--------------\n\n### hasForegroundActivities\n\n```\nboolean hasForegroundActivities (ActivityLifecycleMonitor monitor)\n```\n\nIndicates whether or not an Activity in our app is currently in the foreground.\n\nThe \"Foreground lifetime\" of an activity occurs after a call to onResume and before a call\nto onPause.\n\nDuring this time, the activity is in front of all other activities and is currently\nreceiving user input.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|-------------------------------------------------------------------------|\n| `monitor` | `ActivityLifecycleMonitor`: the ActivityLifecycleMonitor to use. \u003cbr /\u003e |\n\n| Returns ||\n|-----------|------------------------------------------------------------|\n| `boolean` | true if an activity exists in the foreground state. \u003cbr /\u003e |\n\n### hasTransitioningActivities\n\n```\nboolean hasTransitioningActivities (ActivityLifecycleMonitor monitor)\n```\n\nIndicates whether or not an Activity, not in the foreground, exists in our app within the\n\"Visible Lifetime\" state.\n\nThe \"Visible Lifetime\" is defined as an activity where the onStart() method has been called\nbut where the onStop() method has not been called.\n\nDuring this time, the Activity may be visible to the user, and it may be receiving input\nfrom the user. This time is a superset of the \"Foreground lifetime\" of the activity.\n\nIt may be the case that an application has activities in the \"visible lifetime\" but none in\nthe \"Foreground lifetime.\" It may be the case that without user input an activity will shortly\ntransition into the \"Foreground lifetime\" in this state, however it also may not transition\nwithout further user interaction.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|------------------------------------------------------------------------|\n| `monitor` | `ActivityLifecycleMonitor`: the ActivityLifecycleMonitor to use \u003cbr /\u003e |\n\n| Returns ||\n|-----------|----------------------------------------------------------------|\n| `boolean` | true if any activity exists with a transitioning stage. \u003cbr /\u003e |\n\n### hasVisibleActivities\n\n```\nboolean hasVisibleActivities (ActivityLifecycleMonitor monitor)\n```\n\nIndicates whether or not an Activity exists in our app within the \"Visible Lifetime\" state.\n\nThe \"Visible Lifetime\" is defined as an activity where the onStart() method has been called\nbut where the onStop() method has not been called.\n\nDuring this time, the Activity may be visible to the user, and it may be receiving input\nfrom the user. This time is a superset of the \"Foreground lifetime\" of the activity.\n\nIt may be the case that an application has activities in the \"visible lifetime\" but none in\nthe \"Foreground lifetime.\" It may be the case that without user input an activity will shortly\ntransition into the \"Foreground lifetime\" in this state, however it also may not transition\nwithout further user interaction.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|------------------------------------------------------------------------|\n| `monitor` | `ActivityLifecycleMonitor`: the ActivityLifecycleMonitor to use \u003cbr /\u003e |\n\n| Returns ||\n|-----------|---------------------------------------------------------------------|\n| `boolean` | true if any activity exists within it's foreground lifetime. \u003cbr /\u003e |\n\n-\n\n Classes\n -------\n\n - [ActivityLifecycles](/reference/android/support/test/espresso/util/ActivityLifecycles)\n - [EspressoOptional](/reference/android/support/test/espresso/util/EspressoOptional)\n - [HumanReadables](/reference/android/support/test/espresso/util/HumanReadables)\n - [TreeIterables](/reference/android/support/test/espresso/util/TreeIterables)\n - [TreeIterables.ViewAndDistance](/reference/android/support/test/espresso/util/TreeIterables.ViewAndDistance)"]]