Added in API level 35
Builder
class Builder
kotlin.Any | |
↳ | android.app.usage.UsageEventsQuery.Builder |
Builder for UsageEventsQuery.
Summary
Public constructors | |
---|---|
Constructor that specifies the period for which to return events. |
Public methods | |
---|---|
UsageEventsQuery |
build() Builds a read-only UsageEventsQuery object. |
UsageEventsQuery.Builder |
setEventTypes(vararg eventTypes: Int) Sets the list of usage event types to be included in the query. |
UsageEventsQuery.Builder |
setPackageNames(vararg pkgNames: String!) Sets the list of package names to be included in the query. |
Public constructors
Builder
Added in API level 35
Builder(
beginTimeMillis: Long,
endTimeMillis: Long)
Constructor that specifies the period for which to return events.
Parameters | |
---|---|
beginTimeMillis |
Long: Inclusive beginning timestamp, as per java.lang.System#currentTimeMillis() Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. |
endTimeMillis |
Long: Exclusive ending timestamp, as per java.lang.System#currentTimeMillis() Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if beginTimeMillis < endTimeMillis |
Public methods
build
Added in API level 35
fun build(): UsageEventsQuery
Builds a read-only UsageEventsQuery object.
Return | |
---|---|
UsageEventsQuery |
This value cannot be null . |
setEventTypes
Added in API level 35
fun setEventTypes(vararg eventTypes: Int): UsageEventsQuery.Builder
Sets the list of usage event types to be included in the query.
Note:
An empty array will be returned byUsageEventsQuery.getEventTypes()
without calling this method, which indicates querying for all event types. Apps are encouraged to provide a list of event types. Only the matching types supplied will be used to query.
Parameters | |
---|---|
eventTypes |
Int: the array of the usage event types. See UsageEvents.Event . This value cannot be null . Value is android.app.usage.UsageEvents.Event#NONE , android.app.usage.UsageEvents.Event#ACTIVITY_RESUMED , android.app.usage.UsageEvents.Event#ACTIVITY_PAUSED , android.app.usage.UsageEvents.Event.END_OF_DAY, android.app.usage.UsageEvents.Event.CONTINUE_PREVIOUS_DAY, android.app.usage.UsageEvents.Event#CONFIGURATION_CHANGE , android.app.usage.UsageEvents.Event.SYSTEM_INTERACTION, android.app.usage.UsageEvents.Event#USER_INTERACTION , android.app.usage.UsageEvents.Event#SHORTCUT_INVOCATION , android.app.usage.UsageEvents.Event.CHOOSER_ACTION, android.app.usage.UsageEvents.Event.NOTIFICATION_SEEN, android.app.usage.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, android.app.usage.UsageEvents.Event#SCREEN_INTERACTIVE , android.app.usage.UsageEvents.Event#SCREEN_NON_INTERACTIVE , android.app.usage.UsageEvents.Event#KEYGUARD_SHOWN , android.app.usage.UsageEvents.Event#KEYGUARD_HIDDEN , android.app.usage.UsageEvents.Event#FOREGROUND_SERVICE_START , android.app.usage.UsageEvents.Event#FOREGROUND_SERVICE_STOP , android.app.usage.UsageEvents.Event.CONTINUING_FOREGROUND_SERVICE, android.app.usage.UsageEvents.Event.ROLLOVER_FOREGROUND_SERVICE, android.app.usage.UsageEvents.Event#ACTIVITY_STOPPED , android.app.usage.UsageEvents.Event.ACTIVITY_DESTROYED, android.app.usage.UsageEvents.Event.FLUSH_TO_DISK, android.app.usage.UsageEvents.Event#DEVICE_SHUTDOWN , android.app.usage.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 |
Return | |
---|---|
UsageEventsQuery.Builder |
This value cannot be null . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if eventTypes is null or empty. |
java.lang.IllegalArgumentException |
if any of event types are invalid. |
setPackageNames
Added in API level 35
fun setPackageNames(vararg pkgNames: String!): UsageEventsQuery.Builder
Sets the list of package names to be included in the query.
Note:
An emptySet
will be returned by UsageEventsQuery.getPackageNames()
without calling this method, which indicates querying usage events for all packages. Apps are encouraged to provide a list of package names. Only the matching names supplied will be used to query.
Parameters | |
---|---|
pkgNames |
String!: the array of the package names, each package name should be a non-empty string, null or empty string("") is omitted. |
Return | |
---|---|
UsageEventsQuery.Builder |
This value cannot be null . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if pkgNames is null or empty. |