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 | ACTIVITY_PAUSEDAn event type denoting that an  | 
| int | ACTIVITY_RESUMEDAn event type denoting that an  | 
| int | ACTIVITY_STOPPEDAn activity becomes invisible on the UI, corresponding to
  | 
| int | CONFIGURATION_CHANGEAn event type denoting that the device configuration has changed. | 
| int | DEVICE_SHUTDOWNAn event type denoting that the Android runtime underwent a shutdown process. | 
| int | DEVICE_STARTUPAn event type denoting that the Android runtime started up. | 
| int | FOREGROUND_SERVICE_STARTAn event type denoting start of a foreground service. | 
| int | FOREGROUND_SERVICE_STOPAn event type denoting stop of a foreground service. | 
| int | KEYGUARD_HIDDENAn event type denoting that the screen's keyguard has been hidden. | 
| int | KEYGUARD_SHOWNAn event type denoting that the screen's keyguard has been shown, whether or not the screen is off. | 
| int | MOVE_TO_BACKGROUND
      This constant was deprecated
      in API level 29.
    by  | 
| int | MOVE_TO_FOREGROUND
      This constant was deprecated
      in API level 29.
    by  | 
| int | NONENo event type. | 
| int | SCREEN_INTERACTIVEAn 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_INTERACTIVEAn 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_INVOCATIONAn event type denoting that an action equivalent to a ShortcutInfo is taken by the user. | 
| int | STANDBY_BUCKET_CHANGEDAn event type denoting a change in App Standby Bucket. | 
| int | USER_INTERACTIONAn event type denoting that a package was interacted with in some way by the user. | 
| Public constructors | |
|---|---|
| 
      Event()
       | |
| Public methods | |
|---|---|
| 
        
        
        
        
        
        int | 
      getAppStandbyBucket()
      Returns the standby bucket of the app, if the event is of type
  | 
| 
        
        
        
        
        
        String | 
      getClassName()
      The class name of the source of this event. | 
| 
        
        
        
        
        
        Configuration | 
      getConfiguration()
      Returns a  | 
| 
        
        
        
        
        
        int | 
      getEventType()
      The event type. | 
| 
        
        
        
        
        
        PersistableBundle | 
      getExtras()
      Retrieves a map of extended data from the event if the event is of type
  | 
| 
        
        
        
        
        
        String | 
      getPackageName()
      The package name of the source of this event. | 
| 
        
        
        
        
        
        String | 
      getShortcutId()
      Returns the ID of a  | 
| 
        
        
        
        
        
        long | 
      getTimeStamp()
      The time at which this event occurred, measured in milliseconds since the epoch. | 
| Inherited methods | |
|---|---|
Constants
ACTIVITY_PAUSED
public static final int ACTIVITY_PAUSED
An event type denoting that an Activity moved to the background.
 This event has a package name and class name associated with it and can be retrieved
 using getPackageName() and getClassName().
 If a package has multiple activities, this event is reported for each activity that moves
 to background.
 This event is corresponding to Activity.onPause() of the activity's
 lifecycle.
Constant Value: 2 (0x00000002)
ACTIVITY_RESUMED
public static final int ACTIVITY_RESUMED
An event type denoting that an Activity moved to the foreground.
 This event has a package name and class name associated with it and can be retrieved
 using getPackageName() and getClassName().
 If a package has multiple activities, this event is reported for each activity that moves
 to foreground.
 This event is corresponding to Activity.onResume() of the
 activity's lifecycle.
Constant Value: 1 (0x00000001)
ACTIVITY_STOPPED
public static final int ACTIVITY_STOPPED
An activity becomes invisible on the UI, corresponding to
 Activity.onStop() of the activity's lifecycle.
Constant Value: 23 (0x00000017)
CONFIGURATION_CHANGE
public static final int CONFIGURATION_CHANGE
An event type denoting that the device configuration has changed.
Constant Value: 5 (0x00000005)
DEVICE_SHUTDOWN
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 ACTIVITY_STOPPED and
 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 DEVICE_STARTUP should be
 ignored because the closing time is unknown.
Constant Value: 26 (0x0000001a)
DEVICE_STARTUP
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
 DEVICE_SHUTDOWN and DEVICE_STARTUP should be ignored because the closing time is
 unknown.
Constant Value: 27 (0x0000001b)
FOREGROUND_SERVICE_START
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 getPackageName() and getClassName().
 If a package has multiple foreground services, this event is reported for each service
 that is started.
Constant Value: 19 (0x00000013)
FOREGROUND_SERVICE_STOP
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 getPackageName() and getClassName().
 If a package has multiple foreground services, this event is reported for each service
 that is stopped.
Constant Value: 20 (0x00000014)
KEYGUARD_HIDDEN
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
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
public static final int MOVE_TO_BACKGROUND
      This constant was deprecated
      in API level 29.
    by ACTIVITY_PAUSED
  
Constant Value: 2 (0x00000002)
MOVE_TO_FOREGROUND
public static final int MOVE_TO_FOREGROUND
      This constant was deprecated
      in API level 29.
    by ACTIVITY_RESUMED
  
Constant Value: 1 (0x00000001)
NONE
public static final int NONE
No event type.
Constant Value: 0 (0x00000000)
SCREEN_INTERACTIVE
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
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
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
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().
See also:
Constant Value: 11 (0x0000000b)
USER_INTERACTION
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
Public methods
getAppStandbyBucket
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
public String getClassName ()
The class name of the source of this event. This may be null for certain events.
| Returns | |
|---|---|
| String | |
getConfiguration
public Configuration getConfiguration ()
Returns a Configuration for this event if the event is of type
 CONFIGURATION_CHANGE, otherwise it returns null.
| Returns | |
|---|---|
| Configuration | |
getExtras
public PersistableBundle getExtras ()
Retrieves a map of extended data from the event if the event is of type
 USER_INTERACTION.
| Returns | |
|---|---|
| PersistableBundle | the map of all extras that associated with the reported user interaction
         event. The returned PersistableBundlewill contain the extrasUsageStatsManager.EXTRA_EVENT_CATEGORYandUsageStatsManager.EXTRA_EVENT_ACTION.PersistableBundle.EMPTYwill be returned if the details are not available.
 This value cannot benull. | 
getPackageName
public String getPackageName ()
The package name of the source of this event.
| Returns | |
|---|---|
| String | |
getShortcutId
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
public long getTimeStamp ()
The time at which this event occurred, measured in milliseconds since the epoch.
SeeSystem.currentTimeMillis().
 Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z.
| Returns | |
|---|---|
| long | Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. | 
