public
static
final
class
AppUsageDurationQuery.Builder
extends Object
| java.lang.Object | |
| ↳ | android.app.usage.AppUsageDurationQuery.Builder |
Builder for AppUsageDurationQuery.
Public constructors | |
|---|---|
Builder(long startTimeMillis, long endTimeMillis, int intervalType)
Constructor that specifies the period for which to return events. |
|
Public methods | |
|---|---|
AppUsageDurationQuery
|
build()
Builds a read-only |
AppUsageDurationQuery.Builder
|
setEndTimeMillis(long endTimeMillis)
Sets the exclusive end timestamp. |
AppUsageDurationQuery.Builder
|
setIntervalType(int intervalType)
Sets the time interval by which the stats are aggregated. |
AppUsageDurationQuery.Builder
|
setStartTimeMillis(long startTimeMillis)
Sets the inclusive start timestamp. |
Inherited methods | |
|---|---|
public Builder (long startTimeMillis,
long endTimeMillis,
int intervalType)Constructor that specifies the period for which to return events.
startTimeMillislong: inclusive start timestamp, as per System.currentTimeMillis()
endTimeMillislong: exclusive end timestamp, as per System.currentTimeMillis()
intervalTypeint: time interval by which the stats are aggregated.
UsageStatsManager.INTERVAL_DAILYUsageStatsManager.INTERVAL_WEEKLYUsageStatsManager.INTERVAL_MONTHLYUsageStatsManager.INTERVAL_YEARLY| Throws | |
|---|---|
IllegalArgumentException |
if endTimeMillis < startTimeMillis or if
startTimeMillis is negative, or if intervalType is invalid. |
public AppUsageDurationQuery build ()
Builds a read-only AppUsageDurationQuery object.
| Returns | |
|---|---|
AppUsageDurationQuery |
This value cannot be null. |
public AppUsageDurationQuery.Builder setEndTimeMillis (long endTimeMillis)
Sets the exclusive end timestamp.
| Parameters | |
|---|---|
endTimeMillis |
long: exclusive end timestamp, as per System.currentTimeMillis()
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. |
| Returns | |
|---|---|
AppUsageDurationQuery.Builder |
this Builder object.
This value cannot be null. |
public AppUsageDurationQuery.Builder setIntervalType (int intervalType)
Sets the time interval by which the stats are aggregated.
intervalTypeint: time interval by which the stats are aggregated.
UsageStatsManager.INTERVAL_DAILYUsageStatsManager.INTERVAL_WEEKLYUsageStatsManager.INTERVAL_MONTHLYUsageStatsManager.INTERVAL_YEARLY| Returns | |
|---|---|
AppUsageDurationQuery.Builder |
this Builder object.
This value cannot be null. |
public AppUsageDurationQuery.Builder setStartTimeMillis (long startTimeMillis)
Sets the inclusive start timestamp.
| Parameters | |
|---|---|
startTimeMillis |
long: inclusive start timestamp, as per System.currentTimeMillis()
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. |
| Returns | |
|---|---|
AppUsageDurationQuery.Builder |
this Builder object.
This value cannot be null. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-08-28 UTC.