UsageEventsQuery.Builder
public
static
final
class
UsageEventsQuery.Builder
extends Object
| java.lang.Object | |
| ↳ | android.app.usage.UsageEventsQuery.Builder |
Builder for UsageEventsQuery.
Summary
Public constructors | |
|---|---|
Builder(long beginTimeMillis, long endTimeMillis)
Constructor that specifies the period for which to return events. |
|
Public methods | |
|---|---|
UsageEventsQuery
|
build()
Builds a read-only UsageEventsQuery object. |
UsageEventsQuery.Builder
|
setEventTypes(int... eventTypes)
Sets the list of usage event types to be included in the query. |
UsageEventsQuery.Builder
|
setPackageNames(String... pkgNames)
Sets the list of package names to be included in the query. |
Inherited methods | |
|---|---|
Public constructors
Builder
public Builder (long beginTimeMillis,
long endTimeMillis)Constructor that specifies the period for which to return events.
| Parameters | |
|---|---|
beginTimeMillis |
long: Inclusive beginning timestamp, as per
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
System.currentTimeMillis()
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. |
| Throws | |
|---|---|
IllegalArgumentException |
if beginTimeMillis <
endTimeMillis |
Public methods
build
public UsageEventsQuery build ()
Builds a read-only UsageEventsQuery object.
| Returns | |
|---|---|
UsageEventsQuery |
This value cannot be null. |
setEventTypes
public UsageEventsQuery.Builder setEventTypes (int... eventTypes)
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.
| Returns | |
|---|---|
UsageEventsQuery.Builder |
This value cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
if any of event types are invalid. |
NullPointerException |
if eventTypes is null or empty. |
setPackageNames
public UsageEventsQuery.Builder setPackageNames (String... pkgNames)
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. |
| Returns | |
|---|---|
UsageEventsQuery.Builder |
This value cannot be null. |
| Throws | |
|---|---|
NullPointerException |
if pkgNames is null or empty. |