# LocationRequestCompat.Builder

# LocationRequestCompat.Builder

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/location/LocationRequestCompat.java+class:androidx.core.location.LocationRequestCompat.Builder)  
Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/location/LocationRequestCompat.Builder "View this page in Java")

<br />

```
class LocationRequestCompat.Builder
```

<br />

*** ** * ** ***

A builder class for[LocationRequestCompat](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat).

## Summary

|                                                                                                                                                                                      ### Public constructors                                                                                                                                                                                      |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Builder](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#Builder(long))`(intervalMillis: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Creates a new Builder with the given interval.                                                                                                                    |
| [Builder](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#Builder(androidx.core.location.LocationRequestCompat))`(locationRequest: `[LocationRequestCompat](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat)`)` Creates a new Builder with all parameters copied from the given location request. |

|                                                         ### Public functions                                                         |
|--------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [LocationRequestCompat](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat)                 | [build](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#build())`()` Builds a location request from this builder.                                                                                                                                                                                                                                                                                                                                                                                        |
| [LocationRequestCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder) | [clearMinUpdateIntervalMillis](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#clearMinUpdateIntervalMillis())`()` Clears an explicitly set minimum update interval and reverts to an implicit minimum update interval (ie, the minimum update interval is the same value as the interval).                                                                                                                                                                                                              |
| [LocationRequestCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder) | [setDurationMillis](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#setDurationMillis(long))`(durationMillis: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Sets the duration this request will continue before being automatically removed.                                                                                                                    |
| [LocationRequestCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder) | [setIntervalMillis](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#setIntervalMillis(long))`(intervalMillis: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Sets the request interval.                                                                                                                                                                          |
| [LocationRequestCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder) | [setMaxUpdateDelayMillis](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#setMaxUpdateDelayMillis(long))`(maxUpdateDelayMillis: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Sets the maximum time any location update may be delayed, and thus grouped with following updates to enable location batching.                                                    |
| [LocationRequestCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder) | [setMaxUpdates](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#setMaxUpdates(int))`(maxUpdates: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1, to = `[Integer.MAX_VALUE](https://developer.android.com/reference/java/lang/Integer.html#MAX_VALUE)`) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets the maximum number of location updates for this request before this request is automatically removed.   |
| [LocationRequestCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder) | [setMinUpdateDistanceMeters](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#setMinUpdateDistanceMeters(float))`(` ` minUpdateDistanceMeters: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0, to = `[Float.MAX_VALUE](https://developer.android.com/reference/java/lang/Float.html#MAX_VALUE)`) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) `)` Sets the minimum update distance between location updates. |
| [LocationRequestCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder) | [setMinUpdateIntervalMillis](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#setMinUpdateIntervalMillis(long))`(` ` minUpdateIntervalMillis: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) `)` Sets an explicit minimum update interval.                                                                                                                           |
| [LocationRequestCompat.Builder](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder) | [setQuality](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#setQuality(int))`(quality: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets the request quality.                                                                                                                                                                                                                                                                                                        |

## Public constructors

### Builder

Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)  

```
Builder(intervalMillis: Long)
```

Creates a new Builder with the given interval. See[setIntervalMillis](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#setIntervalMillis(long))for more information on the interval. Note that the defaults for various Builder parameters may be different from the defaults for the framework[LocationRequest](https://developer.android.com/reference/android/location/LocationRequest.html).  

### Builder

Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)  

```
Builder(locationRequest: LocationRequestCompat)
```

Creates a new Builder with all parameters copied from the given location request.  

## Public functions

### build

Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)  

```
fun build(): LocationRequestCompat
```

Builds a location request from this builder. If an explicit minimum update interval is set, the minimum update interval of the location request will be the minimum of the interval and minimum update interval.

If building a passive request then you must have set an explicit minimum update interval.  

### clearMinUpdateIntervalMillis

Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)  

```
fun clearMinUpdateIntervalMillis(): LocationRequestCompat.Builder
```

Clears an explicitly set minimum update interval and reverts to an implicit minimum update interval (ie, the minimum update interval is the same value as the interval).  

### setDurationMillis

Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)  

```
fun setDurationMillis(durationMillis: @IntRange(from = 1) Long): LocationRequestCompat.Builder
```

Sets the duration this request will continue before being automatically removed. Defaults to`Long.MAX_VALUE`, which represents an unlimited duration.

**Note:**This parameter will be ignored on platforms below Android Kitkat, and the request will not be removed after the duration expires.  

### setIntervalMillis

Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)  

```
fun setIntervalMillis(intervalMillis: @IntRange(from = 0) Long): LocationRequestCompat.Builder
```

Sets the request interval. The request interval may be set to[PASSIVE_INTERVAL](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat#PASSIVE_INTERVAL())which indicates this request will not actively generate location updates (and thus will not be power blamed for location), but may receive location updates generated as a result of other location requests. A passive request must always have an explicit minimum update interval set.

Locations may be available at a faster interval than specified here, see[setMinUpdateIntervalMillis](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#setMinUpdateIntervalMillis(long))for the behavior in that case.

**Note:** On platforms below Android 12, using the[PASSIVE_INTERVAL](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat#PASSIVE_INTERVAL())will not result in a truly passive request, but a request with an extremely long interval. In most cases, this is effectively the same as a passive request, but this may occasionally result in an initial location calculation for which the client will be blamed.  

### setMaxUpdateDelayMillis

Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)  

```
fun setMaxUpdateDelayMillis(maxUpdateDelayMillis: @IntRange(from = 0) Long): LocationRequestCompat.Builder
```

Sets the maximum time any location update may be delayed, and thus grouped with following updates to enable location batching. If the maximum update delay is equal to or greater than twice the interval, then location providers may provide batched results. Defaults to 0, which represents no batching allowed.  

### setMaxUpdates

Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)  

```
fun setMaxUpdates(maxUpdates: @IntRange(from = 1, to = Integer.MAX_VALUE) Int): LocationRequestCompat.Builder
```

Sets the maximum number of location updates for this request before this request is automatically removed. Defaults to`Integer.MAX_VALUE`, which represents an unlimited number of updates.  

### setMinUpdateDistanceMeters

Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)  

```
fun setMinUpdateDistanceMeters(
    minUpdateDistanceMeters: @FloatRange(from = 0, to = Float.MAX_VALUE) Float
): LocationRequestCompat.Builder
```

Sets the minimum update distance between location updates. If a potential location update is closer to the last location update than the minimum update distance, then the potential location update will not occur. Defaults to 0, which represents no minimum update distance.  

### setMinUpdateIntervalMillis

Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)  

```
fun setMinUpdateIntervalMillis(
    minUpdateIntervalMillis: @IntRange(from = 0) Long
): LocationRequestCompat.Builder
```

Sets an explicit minimum update interval. If location updates are available faster than the request interval then an update will only occur if the minimum update interval has expired since the last location update. Defaults to no explicit minimum update interval set, which means the minimum update interval is the same as the interval.

**Note:**Some allowance for jitter is already built into the minimum update interval, so you need not worry about updates blocked simply because they arrived a fraction of a second earlier than expected.

**Note:** When[build](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat.Builder#build())is invoked, the minimum of the interval and the minimum update interval will be used as the minimum update interval of the built request.  

### setQuality

Added in[1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)  

```
fun setQuality(quality: Int): LocationRequestCompat.Builder
```

Sets the request quality. The quality is a hint to providers on how they should weigh power vs accuracy tradeoffs. High accuracy locations may cost more power to produce, and lower accuracy locations may cost less power to produce. Defaults to[QUALITY_BALANCED_POWER_ACCURACY](https://developer.android.com/reference/kotlin/androidx/core/location/LocationRequestCompat#QUALITY_BALANCED_POWER_ACCURACY()).