Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/app/usage/UsageEvents.Event#constants) \| [Ctors](https://developer.android.com/reference/android/app/usage/UsageEvents.Event#pubctors) \| [Methods](https://developer.android.com/reference/android/app/usage/UsageEvents.Event#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/usage/UsageEvents.Event#inhmethods)

# UsageEvents.Event

*** ** * ** ***

` public static final class UsageEvents.Event `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.usage.UsageEvents.Event |

<br />

*** ** * ** ***

An event representing a state change for a component.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#ACTIVITY_PAUSED` An event type denoting that an `https://developer.android.com/reference/android/app/Activity` moved to the background. |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#ACTIVITY_RESUMED` An event type denoting that an `https://developer.android.com/reference/android/app/Activity` moved to the foreground. |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#ACTIVITY_STOPPED` An activity becomes invisible on the UI, corresponding to `https://developer.android.com/reference/android/app/Activity#onStop()` of the activity's lifecycle. |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#CONFIGURATION_CHANGE` An event type denoting that the device configuration has changed. |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#DEVICE_SHUTDOWN` An event type denoting that the Android runtime underwent a shutdown process. |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#DEVICE_STARTUP` An event type denoting that the Android runtime started up. |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#FOREGROUND_SERVICE_START` An event type denoting start of a foreground service. |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#FOREGROUND_SERVICE_STOP` An event type denoting stop of a foreground service. |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#KEYGUARD_HIDDEN` An event type denoting that the screen's keyguard has been hidden. |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#KEYGUARD_SHOWN` An event type denoting that the screen's keyguard has been shown, whether or not the screen is off. |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#MOVE_TO_BACKGROUND` *This constant was deprecated in API level 29. by `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#ACTIVITY_PAUSED`* |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#MOVE_TO_FOREGROUND` *This constant was deprecated in API level 29. by `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#ACTIVITY_RESUMED`* |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#NONE` No event type. |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#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` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#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` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#SHORTCUT_INVOCATION` An event type denoting that an action equivalent to a ShortcutInfo is taken by the user. |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#STANDBY_BUCKET_CHANGED` An event type denoting a change in App Standby Bucket. |
| `int` | `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#USER_INTERACTION` An event type denoting that a package was interacted with in some way by the user. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/app/usage/UsageEvents.Event#Event()() ` |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getAppStandbyBucket()() ` Returns the standby bucket of the app, if the event is of type `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#STANDBY_BUCKET_CHANGED`, otherwise returns 0. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getClassName()() ` The class name of the source of this event. |
| ` https://developer.android.com/reference/android/content/res/Configuration` | ` https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getConfiguration()() ` Returns a `https://developer.android.com/reference/android/content/res/Configuration` for this event if the event is of type `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#CONFIGURATION_CHANGE`, otherwise it returns null. |
| ` int` | ` https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getEventType()() ` The event type. |
| ` https://developer.android.com/reference/android/os/PersistableBundle` | ` https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getExtras()() ` Retrieves a map of extended data from the event if the event is of type `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#USER_INTERACTION`. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getPackageName()() ` The package name of the source of this event. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getShortcutId()() ` Returns the ID of a `https://developer.android.com/reference/android/content/pm/ShortcutInfo` for this event if the event is of type `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#SHORTCUT_INVOCATION`, otherwise it returns null. |
| ` long` | ` https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getTimeStamp()() ` The time at which this event occurred, measured in milliseconds since the epoch. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### ACTIVITY_PAUSED

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int ACTIVITY_PAUSED
```

An event type denoting that an `https://developer.android.com/reference/android/app/Activity` moved to the background. This event has a package name and class name associated with it and can be retrieved using `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getPackageName()` and `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getClassName()`. If a package has multiple activities, this event is reported for each activity that moves to background. This event is corresponding to `https://developer.android.com/reference/android/app/Activity#onPause()` of the activity's lifecycle.

<br />

Constant Value: 2 (0x00000002)

### ACTIVITY_RESUMED

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int ACTIVITY_RESUMED
```

An event type denoting that an `https://developer.android.com/reference/android/app/Activity` moved to the foreground. This event has a package name and class name associated with it and can be retrieved using `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getPackageName()` and `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getClassName()`. If a package has multiple activities, this event is reported for each activity that moves to foreground. This event is corresponding to `https://developer.android.com/reference/android/app/Activity#onResume()` of the activity's lifecycle.

<br />

Constant Value: 1 (0x00000001)

### ACTIVITY_STOPPED

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int ACTIVITY_STOPPED
```

An activity becomes invisible on the UI, corresponding to `https://developer.android.com/reference/android/app/Activity#onStop()` of the activity's lifecycle.

<br />

Constant Value: 23 (0x00000017)

### CONFIGURATION_CHANGE

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int CONFIGURATION_CHANGE
```

An event type denoting that the device configuration has changed.

<br />

Constant Value: 5 (0x00000005)

### DEVICE_SHUTDOWN

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int DEVICE_SHUTDOWN
```

An event type denoting that the Android runtime underwent a shutdown process. A DEVICE_SHUTDOWN event should be treated as if all started activities and foreground services are now stopped and no explicit `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#ACTIVITY_STOPPED` and `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#FOREGROUND_SERVICE_STOP` events will be generated for them.

The DEVICE_SHUTDOWN timestamp is actually the last time UsageStats database is persisted before the actual shutdown. Events (if there are any) between this timestamp and the actual shutdown is not persisted in the database. So any open events without matching close events between DEVICE_SHUTDOWN and `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#DEVICE_STARTUP` should be ignored because the closing time is unknown.

<br />

<br />

Constant Value: 26 (0x0000001a)

### DEVICE_STARTUP

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int DEVICE_STARTUP
```

An event type denoting that the Android runtime started up. This could be after a shutdown or a runtime restart. Any open events without matching close events between `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#DEVICE_SHUTDOWN` and DEVICE_STARTUP should be ignored because the closing time is unknown.

<br />

Constant Value: 27 (0x0000001b)

### FOREGROUND_SERVICE_START

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int FOREGROUND_SERVICE_START
```

An event type denoting start of a foreground service. This event has a package name and class name associated with it and can be retrieved using `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getPackageName()` and `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getClassName()`. If a package has multiple foreground services, this event is reported for each service that is started.

<br />

Constant Value: 19 (0x00000013)

### FOREGROUND_SERVICE_STOP

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int FOREGROUND_SERVICE_STOP
```

An event type denoting stop of a foreground service. This event has a package name and class name associated with it and can be retrieved using `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getPackageName()` and `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getClassName()`. If a package has multiple foreground services, this event is reported for each service that is stopped.

<br />

Constant Value: 20 (0x00000014)

### KEYGUARD_HIDDEN

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

Constant Value: 18 (0x00000012)

### KEYGUARD_SHOWN

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

Constant Value: 17 (0x00000011)

### MOVE_TO_BACKGROUND

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int MOVE_TO_BACKGROUND
```

<br />

**This constant was deprecated in API level 29.**   

by `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#ACTIVITY_PAUSED`

<br />

<br />

Constant Value: 2 (0x00000002)

### MOVE_TO_FOREGROUND

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int MOVE_TO_FOREGROUND
```

<br />

**This constant was deprecated in API level 29.**   

by `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#ACTIVITY_RESUMED`

<br />

<br />

Constant Value: 1 (0x00000001)

### NONE

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int NONE
```

No event type.

<br />

Constant Value: 0 (0x00000000)

### SCREEN_INTERACTIVE

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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).

<br />

Constant Value: 15 (0x0000000f)

### SCREEN_NON_INTERACTIVE

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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).

<br />

Constant Value: 16 (0x00000010)

### SHORTCUT_INVOCATION

Added in [API level 25](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SHORTCUT_INVOCATION
```

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

<br />

**See also:**

- `https://developer.android.com/reference/android/content/pm/ShortcutManager#reportShortcutUsed(java.lang.String)`

Constant Value: 8 (0x00000008)

### STANDBY_BUCKET_CHANGED

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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 `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#getAppStandbyBucket()`.

<br />

**See also:**

- `https://developer.android.com/reference/android/app/usage/UsageStatsManager#getAppStandbyBucket()`

Constant Value: 11 (0x0000000b)

### USER_INTERACTION

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int USER_INTERACTION
```

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

<br />

Constant Value: 7 (0x00000007)

## Public constructors

### Event

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Event ()
```

<br />

<br />

## Public methods

### getAppStandbyBucket

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getAppStandbyBucket ()
```

Returns the standby bucket of the app, if the event is of type `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#STANDBY_BUCKET_CHANGED`, otherwise returns 0.

<br />

| Returns ||
|---|---|
| `int` | the standby bucket associated with the event. <br /> |

### getClassName

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getClassName ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getConfiguration

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Configuration getConfiguration ()
```

Returns a `https://developer.android.com/reference/android/content/res/Configuration` for this event if the event is of type `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#CONFIGURATION_CHANGE`, otherwise it returns null.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/res/Configuration` | <br /> |

### getEventType

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getEventType ()
```

The event type.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#ACTIVITY_PAUSED`
- `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#ACTIVITY_RESUMED`
- `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#CONFIGURATION_CHANGE`
- `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#USER_INTERACTION`
- `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#STANDBY_BUCKET_CHANGED`
- `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#FOREGROUND_SERVICE_START`
- `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#FOREGROUND_SERVICE_STOP`
- `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#ACTIVITY_STOPPED`

### getExtras

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PersistableBundle getExtras ()
```

Retrieves a map of extended data from the event if the event is of type `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#USER_INTERACTION`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/PersistableBundle` | the map of all extras that associated with the reported user interaction event. The returned `https://developer.android.com/reference/android/os/PersistableBundle` will contain the extras `https://developer.android.com/reference/android/app/usage/UsageStatsManager#EXTRA_EVENT_CATEGORY` and `https://developer.android.com/reference/android/app/usage/UsageStatsManager#EXTRA_EVENT_ACTION`. `https://developer.android.com/reference/android/os/PersistableBundle#EMPTY` will be returned if the details are not available. This value cannot be `null`. <br /> |

### getPackageName

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getPackageName ()
```

The package name of the source of this event.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getShortcutId

Added in [API level 25](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getShortcutId ()
```

Returns the ID of a `https://developer.android.com/reference/android/content/pm/ShortcutInfo` for this event if the event is of type `https://developer.android.com/reference/android/app/usage/UsageEvents.Event#SHORTCUT_INVOCATION`, otherwise it returns null.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/pm/ShortcutManager#reportShortcutUsed(java.lang.String)`

### getTimeStamp

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long getTimeStamp ()
```

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

<br />

See `https://developer.android.com/reference/java/lang/System#currentTimeMillis()`.   
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z.

<br />

<br />

| Returns ||
|---|---|
| `long` | Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. <br /> |