UsageEvents.Event

public static final class UsageEvents.Event
extends Object

java.lang.Object
   ↳ android.app.usage.UsageEvents.Event


An event representing a state change for a component.

Summary

Constants

int CONFIGURATION_CHANGE

An event type denoting that the device configuration has changed.

int KEYGUARD_HIDDEN

An event type denoting that the screen's keyguard has been hidden.

int KEYGUARD_SHOWN

An event type denoting that the screen's keyguard has been shown, whether or not the screen is off.

int MOVE_TO_BACKGROUND

An event type denoting that a component moved to the background.

int MOVE_TO_FOREGROUND

An event type denoting that a component moved to the foreground.

int NONE

No event type.

int SCREEN_INTERACTIVE

An event type denoting that the screen has gone in to an interactive state (turned on for full user interaction, not ambient display or other non-interactive state).

int SCREEN_NON_INTERACTIVE

An event type denoting that the screen has gone in to a non-interactive state (completely turned off or turned on only in a non-interactive state like ambient display).

int SHORTCUT_INVOCATION

An event type denoting that an action equivalent to a ShortcutInfo is taken by the user.

int STANDBY_BUCKET_CHANGED

An event type denoting a change in App Standby Bucket.

int USER_INTERACTION

An event type denoting that a package was interacted with in some way by the user.

Public constructors

UsageEvents.Event()

Public methods

int getAppStandbyBucket()

Returns the standby bucket of the app, if the event is of type STANDBY_BUCKET_CHANGED, otherwise returns 0.

String getClassName()

The class name of the source of this event.

Configuration getConfiguration()

Returns a Configuration for this event if the event is of type CONFIGURATION_CHANGE, otherwise it returns null.

int getEventType()

The event type.

String getPackageName()

The package name of the source of this event.

String getShortcutId()

Returns the ID of a ShortcutInfo for this event if the event is of type SHORTCUT_INVOCATION, otherwise it returns null.

long getTimeStamp()

The time at which this event occurred, measured in milliseconds since the epoch.

Inherited methods

Constants

CONFIGURATION_CHANGE

added in API level 21
public static final int CONFIGURATION_CHANGE

An event type denoting that the device configuration has changed.

Constant Value: 5 (0x00000005)

KEYGUARD_HIDDEN

added in API level 28
public static final int KEYGUARD_HIDDEN

An event type denoting that the screen's keyguard has been hidden. This typically happens when the user unlocks their phone after turning it on.

Constant Value: 18 (0x00000012)

KEYGUARD_SHOWN

added in API level 28
public static final int KEYGUARD_SHOWN

An event type denoting that the screen's keyguard has been shown, whether or not the screen is off.

Constant Value: 17 (0x00000011)

MOVE_TO_BACKGROUND

added in API level 21
public static final int MOVE_TO_BACKGROUND

An event type denoting that a component moved to the background.

Constant Value: 2 (0x00000002)

MOVE_TO_FOREGROUND

added in API level 21
public static final int MOVE_TO_FOREGROUND

An event type denoting that a component moved to the foreground.

Constant Value: 1 (0x00000001)

NONE

added in API level 21
public static final int NONE

No event type.

Constant Value: 0 (0x00000000)

SCREEN_INTERACTIVE

added in API level 28
public static final int SCREEN_INTERACTIVE

An event type denoting that the screen has gone in to an interactive state (turned on for full user interaction, not ambient display or other non-interactive state).

Constant Value: 15 (0x0000000f)

SCREEN_NON_INTERACTIVE

added in API level 28
public static final int SCREEN_NON_INTERACTIVE

An event type denoting that the screen has gone in to a non-interactive state (completely turned off or turned on only in a non-interactive state like ambient display).

Constant Value: 16 (0x00000010)

SHORTCUT_INVOCATION

added in API level 25
public static final int SHORTCUT_INVOCATION

An event type denoting that an action equivalent to a ShortcutInfo is taken by the user.

Constant Value: 8 (0x00000008)

STANDBY_BUCKET_CHANGED

added in API level 28
public static final int STANDBY_BUCKET_CHANGED

An event type denoting a change in App Standby Bucket. The new bucket can be retrieved by calling getAppStandbyBucket().

Constant Value: 11 (0x0000000b)

USER_INTERACTION

added in API level 23
public static final int USER_INTERACTION

An event type denoting that a package was interacted with in some way by the user.

Constant Value: 7 (0x00000007)

Public constructors

UsageEvents.Event

added in API level 21
public UsageEvents.Event ()

Public methods

getAppStandbyBucket

added in API level 28
public int getAppStandbyBucket ()

Returns the standby bucket of the app, if the event is of type STANDBY_BUCKET_CHANGED, otherwise returns 0.

Returns
int the standby bucket associated with the event.

getClassName

added in API level 21
public String getClassName ()

The class name of the source of this event. This may be null for certain events.

Returns
String

getConfiguration

added in API level 21
public Configuration getConfiguration ()

Returns a Configuration for this event if the event is of type CONFIGURATION_CHANGE, otherwise it returns null.

Returns
Configuration

getEventType

added in API level 21
public int getEventType ()

The event type.

Returns
int

getPackageName

added in API level 21
public String getPackageName ()

The package name of the source of this event.

Returns
String

getShortcutId

added in API level 25
public String getShortcutId ()

Returns the ID of a ShortcutInfo for this event if the event is of type SHORTCUT_INVOCATION, otherwise it returns null.

Returns
String

getTimeStamp

added in API level 21
public long getTimeStamp ()

The time at which this event occurred, measured in milliseconds since the epoch.

See System.currentTimeMillis().

Returns
long