public final class

ActivityLifecycles

extends Object
java.lang.Object
   ↳ android.support.test.espresso.util.ActivityLifecycles

Class Overview

Helper methods to understand ActivityLifecycle of the app.

Summary

Public Methods
static boolean hasForegroundActivities(ActivityLifecycleMonitor monitor)
Indicates whether or not an Activity in our app is currently in the foreground.
static boolean hasVisibleActivities(ActivityLifecycleMonitor monitor)
Indicates whether or not an Activity exists in our app within the "Visible Lifetime" state.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static 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.

Parameters
monitor the ActivityLifecycleMonitor to use.
Returns
  • true if an activity exists in the foreground state.

public static 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 who's onStart() method has been called but who's 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 the ActivityLifecycleMonitor to use
Returns
  • true if any activity exists within it's foreground lifetime.