ActivityLifecycles


public final class ActivityLifecycles


Helper methods to understand ActivityLifecycle of the app.

Summary

Public methods

static boolean

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

static boolean

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

static boolean

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

Public methods

hasForegroundActivities

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
ActivityLifecycleMonitor monitor

the ActivityLifecycleMonitor to use.

Returns
boolean

true if an activity exists in the foreground state.

hasTransitioningActivities

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

Parameters
ActivityLifecycleMonitor monitor

the ActivityLifecycleMonitor to use

Returns
boolean

true if any activity exists with a transitioning stage.

hasVisibleActivities

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 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
ActivityLifecycleMonitor monitor

the ActivityLifecycleMonitor to use

Returns
boolean

true if any activity exists within it's foreground lifetime.