LocationRequestCompat

public final class LocationRequestCompat
extends Object

java.lang.Object
   ↳ androidx.core.location.LocationRequestCompat


Compatibility version of LocationRequest.

Summary

Nested classes

class LocationRequestCompat.Builder

A builder class for LocationRequestCompat

Constants

long PASSIVE_INTERVAL

Represents a passive only request.

int QUALITY_BALANCED_POWER_ACCURACY

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

int QUALITY_HIGH_ACCURACY

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.

int QUALITY_LOW_POWER

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

Public methods

boolean equals(Object o)
long getDurationMillis()

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

long getIntervalMillis()

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

long getMaxUpdateDelayMillis()

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

int getMaxUpdates()

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

float getMinUpdateDistanceMeters()

Returns the minimum distance between location updates.

long getMinUpdateIntervalMillis()

Returns the minimum update interval.

int getQuality()

Returns the quality hint for this location request.

int hashCode()
LocationRequest toLocationRequest(String provider)

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

LocationRequest toLocationRequest()

Converts an instance to an equivalent LocationRequest.

String toString()

Inherited methods

Constants

PASSIVE_INTERVAL

public static final long PASSIVE_INTERVAL

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.

Constant Value: 9223372036854775807 (0x7fffffffffffffff)

QUALITY_BALANCED_POWER_ACCURACY

public static final int QUALITY_BALANCED_POWER_ACCURACY

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.

Constant Value: 102 (0x00000066)

QUALITY_HIGH_ACCURACY

public static final int QUALITY_HIGH_ACCURACY

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.

Constant Value: 100 (0x00000064)

QUALITY_LOW_POWER

public static final int QUALITY_LOW_POWER

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.

Constant Value: 104 (0x00000068)

Public methods

equals

public boolean equals (Object o)

Parameters
o Object

Returns
boolean

getDurationMillis

public long getDurationMillis ()

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
long the duration for which location will be provided

Value is 1 or greater.

getIntervalMillis

public long getIntervalMillis ()

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.

Returns
long

getMaxUpdateDelayMillis

public long getMaxUpdateDelayMillis ()

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
long the maximum time by which a location update may be delayed

See also: