LocationRequestCompat

Added in 1.7.0

class LocationRequestCompat


Compatibility version of LocationRequest.

Summary

Nested types

A builder class for LocationRequestCompat.

Constants

const Long
PASSIVE_INTERVAL = 9223372036854775807

Represents a passive only request.

const Int

A quality constant indicating a location provider may choose to satisfy this request by equally balancing power and accuracy constraints.

const Int

A quality constant indicating a location provider may choose to satisfy this request by providing very accurate locations at the expense of potentially increased power usage.

const Int

A quality constant indicating a location provider may choose to satisfy this request by providing less accurate locations in order to save power.

Public functions

Boolean
equals(o: Any!)
@IntRange(from = 1) Long

Returns the duration for which location will be provided before the request is automatically removed.

@IntRange(from = 0) Long

Returns the desired interval of location updates, or PASSIVE_INTERVAL if this is a passive, no power request.

@IntRange(from = 0) Long

Returns the maximum time any location update may be delayed, and thus grouped with following updates to enable location batching.

@IntRange(from = 1, to = Integer.MAX_VALUE) Int

Returns the maximum number of location updates for this request before the request is automatically removed.

@FloatRange(from = 0, to = Float.MAX_VALUE) Float

Returns the minimum distance between location updates.

@IntRange(from = 0) Long

Returns the minimum update interval.

Int

Returns the quality hint for this location request.

Int
LocationRequest

Converts an instance to an equivalent LocationRequest.

LocationRequest?

Converts an instance to an equivalent LocationRequest, with the provider field of the resulting LocationRequest set to the provider argument provided to this method.

String

Constants

PASSIVE_INTERVAL

Added in 1.7.0
const val PASSIVE_INTERVAL = 9223372036854775807: Long

Represents a passive only request. Such a request will not trigger any active locations or power usage itself, but may receive locations generated in response to other requests.

QUALITY_BALANCED_POWER_ACCURACY

Added in 1.7.0
const val QUALITY_BALANCED_POWER_ACCURACY = 102: Int

A quality constant indicating a location provider may choose to satisfy this request by equally balancing power and accuracy constraints. Each location provider may interpret this field differently, but location providers will generally use their default behavior when this flag is present.

QUALITY_HIGH_ACCURACY

Added in 1.7.0
const val QUALITY_HIGH_ACCURACY = 100: Int

A quality constant indicating a location provider may choose to satisfy this request by providing very accurate locations at the expense of potentially increased power usage. Each location provider may interpret this field differently, but as an example, the network provider may choose to return only wifi based locations rather than cell based locations in order to have greater accuracy when this flag is present.

QUALITY_LOW_POWER

Added in 1.7.0
const val QUALITY_LOW_POWER = 104: Int

A quality constant indicating a location provider may choose to satisfy this request by providing less accurate locations in order to save power. Each location provider may interpret this field differently, but as an example, the network provider may choose to return cell based locations rather than wifi based locations in order to save power when this flag is present.

Public functions

equals

fun equals(o: Any!): Boolean

getDurationMillis

Added in 1.7.0
fun getDurationMillis(): @IntRange(from = 1) Long

Returns the duration for which location will be provided before the request is automatically removed. A duration of Long.MAX_VALUE represents an unlimited duration.

Returns
@IntRange(from = 1) Long

the duration for which location will be provided

getIntervalMillis

Added in 1.7.0
fun getIntervalMillis(): @IntRange(from = 0) Long

Returns the desired interval of location updates, or PASSIVE_INTERVAL if this is a passive, no power request. A passive 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 getMinUpdateIntervalMillis for the behavior in that case.

getMaxUpdateDelayMillis

Added in 1.7.0
fun getMaxUpdateDelayMillis(): @IntRange(from = 0) Long

Returns 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. The maximum batch size is the maximum update delay divided by the interval. Not all devices or location providers support batching, and use of this parameter does not guarantee that the client will see batched results, or that batched results will always be of the maximum size. When available, batching can provide substantial power savings to the device, and clients are encouraged to take advantage where appropriate for the use case.

Returns
@IntRange(from = 0) Long

the maximum time by which a location update may be delayed

getMaxUpdates

Added in 1.7.0
fun getMaxUpdates(): @IntRange(from = 1, to = Integer.MAX_VALUE) Int

Returns the maximum number of location updates for this request before the request is automatically removed. A max updates value of Integer.MAX_VALUE represents an unlimited number of updates.

getMinUpdateDistanceMeters

Added in 1.7.0
fun getMinUpdateDistanceMeters(): @FloatRange(from = 0, to = Float.MAX_VALUE) Float

Returns the minimum 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. A value of 0 meters implies that no location update will ever be rejected due to failing this constraint.

Returns
@FloatRange(from = 0, to = Float.MAX_VALUE) Float

the minimum distance between location updates

getMinUpdateIntervalMillis

Added in 1.7.0
fun getMinUpdateIntervalMillis(): @IntRange(from = 0) Long

Returns the minimum update interval. If location updates are available faster than the request interval then locations will only be updated if the minimum update interval has expired since the last location update.

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.

Returns
@IntRange(from = 0) Long

the minimum update interval

getQuality

Added in 1.7.0
fun getQuality(): Int

Returns the quality hint for this location request. The quality hint informs the provider how it should attempt to manage any accuracy vs power tradeoffs while attempting to satisfy this location request.

hashCode

fun hashCode(): Int

toLocationRequest

Added in 1.7.0
@RequiresApi(value = 31)
fun toLocationRequest(): LocationRequest

Converts an instance to an equivalent LocationRequest.

Returns
LocationRequest

platform class object

See also
LocationRequest

toLocationRequest

Added in 1.7.0
fun toLocationRequest(provider: String): LocationRequest?

Converts an instance to an equivalent LocationRequest, with the provider field of the resulting LocationRequest set to the provider argument provided to this method.

May return null on some SDKs if various reflective operations fail. This should only occur on non-standard Android devices, and thus should be rare.

Returns
LocationRequest?

platform class object

See also
LocationRequest

toString

fun toString(): String