UsageEventsQuery


public final class UsageEventsQuery
extends Object implements Parcelable

java.lang.Object
   ↳ android.app.usage.UsageEventsQuery


An Object-Oriented representation for a UsageEvents query. Used by UsageStatsManager#queryEvents(UsageEventsQuery) call.

Summary

Nested classes

class UsageEventsQuery.Builder

Builder for UsageEventsQuery. 

Inherited constants

Fields

public static final Creator<UsageEventsQuery> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

long getBeginTimeMillis()

Returns the inclusive timestamp to indicate the beginning of the range of events.

long getEndTimeMillis()

Returns the exclusive timpstamp to indicate the end of the range of events.

int[] getEventTypes()

Retrieves the usage event types for the query.

Set<String> getPackageNames()

Retrieves a Set of package names for the query.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Fields

CREATOR

Added in API level 35
public static final Creator<UsageEventsQuery> CREATOR

Public methods

describeContents

Added in API level 35
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR

getBeginTimeMillis

Added in API level 35
public long getBeginTimeMillis ()

Returns the inclusive timestamp to indicate the beginning of the range of events. Defined in terms of "Unix time", see System.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.

getEndTimeMillis

Added in API level 35
public long getEndTimeMillis ()

Returns the exclusive timpstamp to indicate the end of the range of events. Defined in terms of "Unix time", see System.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.

getEventTypes

Added in API level 35
public int[] getEventTypes ()

Retrieves the usage event types for the query.

Note that an empty array indicates querying all usage event types, and it may cause additional system overhead when calling UsageStatsManager#queryEvents(UsageEventsQuery). Apps are encouraged to provide a list of event types via Builder#setEventTypes(int...)

Returns
int[] an array contains the usage event types that was previously set using Builder#setEventTypes(int...) or an empty array if no value has been set. This value cannot be null. Value is UsageEvents.Event.NONE, UsageEvents.Event.ACTIVITY_RESUMED, UsageEvents.Event.ACTIVITY_PAUSED, android.app.usage.UsageEvents.Event.END_OF_DAY, android.app.usage.UsageEvents.Event.CONTINUE_PREVIOUS_DAY, UsageEvents.Event.CONFIGURATION_CHANGE, android.app.usage.UsageEvents.Event.SYSTEM_INTERACTION, UsageEvents.Event.USER_INTERACTION, UsageEvents.Event.SHORTCUT_INVOCATION, android.app.usage.UsageEvents.Event.CHOOSER_ACTION, android.app.usage.UsageEvents.Event.NOTIFICATION_SEEN, UsageEvents.Event.STANDBY_BUCKET_CHANGED, android.app.usage.UsageEvents.Event.NOTIFICATION_INTERRUPTION, android.app.usage.UsageEvents.Event.SLICE_PINNED_PRIV, android.app.usage.UsageEvents.Event.SLICE_PINNED, UsageEvents.Event.SCREEN_INTERACTIVE, UsageEvents.Event.SCREEN_NON_INTERACTIVE, UsageEvents.Event.KEYGUARD_SHOWN, UsageEvents.Event.KEYGUARD_HIDDEN, UsageEvents.Event.FOREGROUND_SERVICE_START, UsageEvents.Event.FOREGROUND_SERVICE_STOP, android.app.usage.UsageEvents.Event.CONTINUING_FOREGROUND_SERVICE, android.app.usage.UsageEvents.Event.ROLLOVER_FOREGROUND_SERVICE, UsageEvents.Event.ACTIVITY_STOPPED, android.app.usage.UsageEvents.Event.ACTIVITY_DESTROYED, android.app.usage.UsageEvents.Event.FLUSH_TO_DISK, UsageEvents.Event.DEVICE_SHUTDOWN, UsageEvents.Event.DEVICE_STARTUP, android.app.usage.UsageEvents.Event.USER_UNLOCKED, android.app.usage.UsageEvents.Event.USER_STOPPED, android.app.usage.UsageEvents.Event.LOCUS_ID_SET, or android.app.usage.UsageEvents.Event.APP_COMPONENT_USED

getPackageNames

Added in API level 35
public Set<String> getPackageNames ()

Retrieves a Set of package names for the query.

Note that an empty set indicates querying usage events for all packages, and it may cause additional system overhead when calling UsageStatsManager#queryEvents(UsageEventsQuery). Apps are encouraged to provide a list of package names via Builder#setPackageNames(String...)

Returns
Set<String> a Set contains the package names that was previously set through Builder#setPackageNames(String...) or an empty set if no value has been set. This value cannot be null.

writeToParcel

Added in API level 35
public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES