# LocationRequest.Builder

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/location/LocationRequest.Builder#pubctors)\|[Methods](https://developer.android.com/reference/android/location/LocationRequest.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/location/LocationRequest.Builder#inhmethods)  

# LocationRequest.Builder

*** ** * ** ***

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

`
public
static
final

class
LocationRequest.Builder
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.location.LocationRequest.Builder |

<br />

*** ** * ** ***

A builder class for[LocationRequest](https://developer.android.com/reference/android/location/LocationRequest).

## Summary

|                                                                                                                                                             ### Public constructors                                                                                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder#Builder(android.location.LocationRequest))`(`[LocationRequest](https://developer.android.com/reference/android/location/LocationRequest)` locationRequest) ` Creates a new Builder with all parameters copied from the given location request. |
| ` `[Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder#Builder(long))`(long intervalMillis) ` Creates a new Builder with the given interval.                                                                                                                                                          |

|                                                                                                                                                                                                                         ### Public methods                                                                                                                                                                                                                         ||
|----------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[LocationRequest](https://developer.android.com/reference/android/location/LocationRequest)                 | ` `[build](https://developer.android.com/reference/android/location/LocationRequest.Builder#build())`() ` Builds a location request from this builder.                                                                                                                                                                                             |
| ` `[LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | ` `[clearMinUpdateIntervalMillis](https://developer.android.com/reference/android/location/LocationRequest.Builder#clearMinUpdateIntervalMillis())`() ` Clears an explicitly set minimum update interval and reverts to an implicit minimum update interval (ie, the minimum update interval is some sensible default between 0 and the interval). |
| ` `[LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | ` `[setDurationMillis](https://developer.android.com/reference/android/location/LocationRequest.Builder#setDurationMillis(long))`(long durationMillis) ` Sets the duration this request will continue before being automatically removed.                                                                                                          |
| ` `[LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | ` `[setIntervalMillis](https://developer.android.com/reference/android/location/LocationRequest.Builder#setIntervalMillis(long))`(long intervalMillis) ` Sets the request interval.                                                                                                                                                                |
| ` `[LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | ` `[setMaxUpdateDelayMillis](https://developer.android.com/reference/android/location/LocationRequest.Builder#setMaxUpdateDelayMillis(long))`(long maxUpdateDelayMillis) ` Sets the maximum time any location update may be delayed, and thus grouped with following updates to enable location batching.                                          |
| ` `[LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | ` `[setMaxUpdates](https://developer.android.com/reference/android/location/LocationRequest.Builder#setMaxUpdates(int))`(int maxUpdates) ` Sets the maximum number of location updates for this request before this request is automatically removed.                                                                                              |
| ` `[LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | ` `[setMinUpdateDistanceMeters](https://developer.android.com/reference/android/location/LocationRequest.Builder#setMinUpdateDistanceMeters(float))`(float minUpdateDistanceMeters) ` Sets the minimum update distance between location updates.                                                                                                   |
| ` `[LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | ` `[setMinUpdateIntervalMillis](https://developer.android.com/reference/android/location/LocationRequest.Builder#setMinUpdateIntervalMillis(long))`(long minUpdateIntervalMillis) ` Sets an explicit minimum update interval.                                                                                                                      |
| ` `[LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | ` `[setQuality](https://developer.android.com/reference/android/location/LocationRequest.Builder#setQuality(int))`(int quality) ` Sets the request quality.                                                                                                                                                                                        |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Builder (LocationRequest locationRequest)
```

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

<br />

|                                Parameters                                ||
|-------------------|-------------------------------------------------------|
| `locationRequest` | `LocationRequest`: This value cannot be`null`. <br /> |

### Builder

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Builder (long intervalMillis)
```

Creates a new Builder with the given interval. See[setIntervalMillis(long)](https://developer.android.com/reference/android/location/LocationRequest.Builder#setIntervalMillis(long))for more information on the interval.

<br />

|           Parameters            ||
|------------------|---------------|
| `intervalMillis` | `long` <br /> |

## Public methods

### build

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LocationRequest build ()
```

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.

<br />

|                                                                        Returns                                                                         ||
|---------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| [LocationRequest](https://developer.android.com/reference/android/location/LocationRequest) | a new location request This value cannot be`null`. <br /> |

|                                                                                    Throws                                                                                    ||
|--------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if building a passive request with no explicit minimum update interval set |

### clearMinUpdateIntervalMillis

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LocationRequest.Builder clearMinUpdateIntervalMillis ()
```

Clears an explicitly set minimum update interval and reverts to an implicit minimum update interval (ie, the minimum update interval is some sensible default between 0 and the interval).

<br />

|                                                                     Returns                                                                     ||
|-------------------------------------------------------------------------------------------------------------|------------------------------------|
| [LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | This value cannot be`null`. <br /> |

### setDurationMillis

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LocationRequest.Builder setDurationMillis (long durationMillis)
```

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

<br />

|                       Parameters                       ||
|------------------|--------------------------------------|
| `durationMillis` | `long`: Value is 1 or greater <br /> |

|                                                                     Returns                                                                     ||
|-------------------------------------------------------------------------------------------------------------|------------------------------------|
| [LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | This value cannot be`null`. <br /> |

### setIntervalMillis

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LocationRequest.Builder setIntervalMillis (long intervalMillis)
```

Sets the request interval. The request interval may be set to[LocationRequest.PASSIVE_INTERVAL](https://developer.android.com/reference/android/location/LocationRequest#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(long)](https://developer.android.com/reference/android/location/LocationRequest.Builder#setMinUpdateIntervalMillis(long))for the behavior in that case.

<br />

|                       Parameters                       ||
|------------------|--------------------------------------|
| `intervalMillis` | `long`: Value is 0 or greater <br /> |

|                                                                     Returns                                                                     ||
|-------------------------------------------------------------------------------------------------------------|------------------------------------|
| [LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | This value cannot be`null`. <br /> |

### setMaxUpdateDelayMillis

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LocationRequest.Builder setMaxUpdateDelayMillis (long maxUpdateDelayMillis)
```

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.

<br />

|                          Parameters                          ||
|------------------------|--------------------------------------|
| `maxUpdateDelayMillis` | `long`: Value is 0 or greater <br /> |

|                                                                     Returns                                                                     ||
|-------------------------------------------------------------------------------------------------------------|------------------------------------|
| [LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | This value cannot be`null`. <br /> |

### setMaxUpdates

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LocationRequest.Builder setMaxUpdates (int maxUpdates)
```

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.

<br />

|                                                                     Parameters                                                                      ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------|
| `maxUpdates` | `int`: Value is between 1 and[Integer.MAX_VALUE](https://developer.android.com/reference/java/lang/Integer#MAX_VALUE)inclusive <br /> |

|                                                                     Returns                                                                     ||
|-------------------------------------------------------------------------------------------------------------|------------------------------------|
| [LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | This value cannot be`null`. <br /> |

### setMinUpdateDistanceMeters

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LocationRequest.Builder setMinUpdateDistanceMeters (float minUpdateDistanceMeters)
```

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.

<br />

|                                                                            Parameters                                                                             ||
|---------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| `minUpdateDistanceMeters` | `float`: Value is between 0.0f and[Float.MAX_VALUE](https://developer.android.com/reference/java/lang/Float#MAX_VALUE)inclusive <br /> |

|                                                                     Returns                                                                     ||
|-------------------------------------------------------------------------------------------------------------|------------------------------------|
| [LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | This value cannot be`null`. <br /> |

### setMinUpdateIntervalMillis

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LocationRequest.Builder setMinUpdateIntervalMillis (long minUpdateIntervalMillis)
```

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 some sensible default between 0 and the interval will be chosen. The exact value is not specified at the moment. If an exact known value is required, clients should set an explicit value themselves.

**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/android/location/LocationRequest.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.

<br />

|                           Parameters                            ||
|---------------------------|--------------------------------------|
| `minUpdateIntervalMillis` | `long`: Value is 0 or greater <br /> |

|                                                                     Returns                                                                     ||
|-------------------------------------------------------------------------------------------------------------|------------------------------------|
| [LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | This value cannot be`null`. <br /> |

### setQuality

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LocationRequest.Builder setQuality (int quality)
```

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[LocationRequest.QUALITY_BALANCED_POWER_ACCURACY](https://developer.android.com/reference/android/location/LocationRequest#QUALITY_BALANCED_POWER_ACCURACY).

<br />

|                                                                                                                                                                                                                               Parameters                                                                                                                                                                                                                                ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `quality` | `int`: Value is[LocationRequest.QUALITY_LOW_POWER](https://developer.android.com/reference/android/location/LocationRequest#QUALITY_LOW_POWER),[LocationRequest.QUALITY_BALANCED_POWER_ACCURACY](https://developer.android.com/reference/android/location/LocationRequest#QUALITY_BALANCED_POWER_ACCURACY), or[LocationRequest.QUALITY_HIGH_ACCURACY](https://developer.android.com/reference/android/location/LocationRequest#QUALITY_HIGH_ACCURACY) <br /> |

|                                                                     Returns                                                                     ||
|-------------------------------------------------------------------------------------------------------------|------------------------------------|
| [LocationRequest.Builder](https://developer.android.com/reference/android/location/LocationRequest.Builder) | This value cannot be`null`. <br /> |