Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions) Summary: [Ctors](https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder#inhmethods)

# AppUsageDurationQuery.Builder

*** ** * ** ***


`
public
static
final

class
AppUsageDurationQuery.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.usage.AppUsageDurationQuery.Builder |

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery`.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder#Builder(long,%20long,%20int)(long startTimeMillis, long endTimeMillis, int intervalType) ` Constructor that specifies the period for which to return events. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery` | ` https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder#build()() ` Builds a read-only `https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery` object. |
| ` https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder` | ` https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder#setEndTimeMillis(long)(long endTimeMillis) ` Sets the exclusive end timestamp. |
| ` https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder` | ` https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder#setIntervalType(int)(int intervalType) ` Sets the time interval by which the stats are aggregated. |
| ` https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder` | ` https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder#setStartTimeMillis(long)(long startTimeMillis) ` Sets the inclusive start timestamp. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


## Public constructors

### Builder

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public Builder (long startTimeMillis, 
                long endTimeMillis, 
                int intervalType)
```

Constructor that specifies the period for which to return events.

<br />

| Parameters ||
|---|---|
| `startTimeMillis` | `long`: inclusive start timestamp, as per `https://developer.android.com/reference/java/lang/System#currentTimeMillis()` Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. <br /> |
| `endTimeMillis` | `long`: exclusive end timestamp, as per `https://developer.android.com/reference/java/lang/System#currentTimeMillis()` Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. <br /> |
| `intervalType` | `int`: time interval by which the stats are aggregated. Value is one of the following: - `https://developer.android.com/reference/android/app/usage/UsageStatsManager#INTERVAL_DAILY` - `https://developer.android.com/reference/android/app/usage/UsageStatsManager#INTERVAL_WEEKLY` - `https://developer.android.com/reference/android/app/usage/UsageStatsManager#INTERVAL_MONTHLY` - `https://developer.android.com/reference/android/app/usage/UsageStatsManager#INTERVAL_YEARLY` |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `endTimeMillis` \< `startTimeMillis` or if `startTimeMillis` is negative, or if `intervalType` is invalid. |

## Public methods

### build

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public AppUsageDurationQuery build ()
```

Builds a read-only `https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery` object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery` | This value cannot be `null`. <br /> |

### setEndTimeMillis

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public AppUsageDurationQuery.Builder setEndTimeMillis (long endTimeMillis)
```

Sets the exclusive end timestamp.

<br />

| Parameters ||
|---|---|
| `endTimeMillis` | `long`: exclusive end timestamp, as per `https://developer.android.com/reference/java/lang/System#currentTimeMillis()` Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder` | this `https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder` object. This value cannot be `null`. <br /> |

### setIntervalType

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public AppUsageDurationQuery.Builder setIntervalType (int intervalType)
```

Sets the time interval by which the stats are aggregated.

<br />

| Parameters ||
|---|---|
| `intervalType` | `int`: time interval by which the stats are aggregated. Value is one of the following: - `https://developer.android.com/reference/android/app/usage/UsageStatsManager#INTERVAL_DAILY` - `https://developer.android.com/reference/android/app/usage/UsageStatsManager#INTERVAL_WEEKLY` - `https://developer.android.com/reference/android/app/usage/UsageStatsManager#INTERVAL_MONTHLY` - `https://developer.android.com/reference/android/app/usage/UsageStatsManager#INTERVAL_YEARLY` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder` | this `https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder` object. This value cannot be `null`. <br /> |

### setStartTimeMillis

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public AppUsageDurationQuery.Builder setStartTimeMillis (long startTimeMillis)
```

Sets the inclusive start timestamp.

<br />

| Parameters ||
|---|---|
| `startTimeMillis` | `long`: inclusive start timestamp, as per `https://developer.android.com/reference/java/lang/System#currentTimeMillis()` Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder` | this `https://developer.android.com/reference/android/app/usage/AppUsageDurationQuery.Builder` object. This value cannot be `null`. <br /> |