An encapsulation of various parameters for requesting location through FusedLocationProviderClient.
There are a variety of different situations where various types of applications may want
to use different request parameters. For example, applications that are showing the user's
location in realtime may consider a
PRIORITY_HIGH_ACCURACY request with a short interval. At the other extreme, an
application that want a negligible power impact while still receiving opportunistic locations
could create PRIORITY_NO_POWER
request. With this request the application will not trigger any location updates, but can
still receive locations updates triggered by other application's location requests. In
between these use cases an application can consider a
PRIORITY_BALANCED_POWER_ACCURACY request with a reasonable interval and fastest
interval. See the documentation around the various parameters of LocationRequest for more
information.
Applications should strongly consider using
setFastestInterval(long) to limit the fastest rate at which their location
callbacks can be invoked (and thus limit the amount of power used and that they may be blamed
for).
Applications cannot specify the exact sensors, such as GNSS, that will be used in order to satisfy location requests. In fact, the Fused Location Provider may fuse the results from many different sensors into a single location.
Location requests from applications with only the Manifest.permission.ACCESS_COARSE_LOCATION
permission may be throttled to a slower interval, and the returned location will be
obfuscated to only show a coarse level of accuracy.
Many location requests parameters are considered hints, and you may receive locations that are more/less accurate and faster/slower than expected.
| class | LocationRequest.Builder | Builder for LocationRequest. |
|
| int | PRIORITY_BALANCED_POWER_ACCURACY | This constant is deprecated. Use
Priority.PRIORITY_BALANCED_POWER_ACCURACY instead. |
| int | PRIORITY_HIGH_ACCURACY | This constant is deprecated. Use
Priority.PRIORITY_HIGH_ACCURACY instead. |
| int | PRIORITY_LOW_POWER | This constant is deprecated. Use
Priority.PRIORITY_LOW_POWER instead. |
| int | PRIORITY_NO_POWER | This constant is deprecated. Use
Priority.PRIORITY_PASSIVE
instead. |
| static LocationRequest |
create()
This method is deprecated. Use
LocationRequest.Builder instead. May be removed in a future
release.
|
| boolean | |
| long |
getDurationMillis()
The duration of this request.
|
| long |
getExpirationTime()
This method is deprecated. Use
getDurationMillis() instead. Using this method will return the
duration added to the current elapsed realtime, which may give unexpected
results. May be removed in a future release.
|
| long |
getFastestInterval()
This method is deprecated. Use
getMinUpdateIntervalMillis() instead. May be removed in a future
release.
|
| int |
getGranularity()
The
Granularity
of locations returned for this request.
|
| long |
getInterval()
This method is deprecated. Use
getIntervalMillis() instead. May be removed in a future
release.
|
| long |
getIntervalMillis()
The desired interval of location updates.
|
| long |
getMaxUpdateAgeMillis()
The maximum age of an initial historical location delivered for this request.
|
| long |
getMaxUpdateDelayMillis()
The longest a location update may be delayed.
|
| int |
getMaxUpdates()
The maximum number of updates delivered to this request.
|
| long |
getMaxWaitTime()
This method is deprecated. Use
getMaxUpdateDelayMillis() instead. May be removed in a future
release.
|
| float |
getMinUpdateDistanceMeters()
The minimum distance required between consecutive location updates.
|
| long |
getMinUpdateIntervalMillis()
The fastest allowed interval of location updates.
|
| int |
getNumUpdates()
This method is deprecated. Use
getMaxUpdates() instead. May be removed in a future release.
|
| int |
getPriority()
The
Priority
of the location request.
|
| float |
getSmallestDisplacement()
This method is deprecated. Use
getMinUpdateDistanceMeters() instead.
|
| int |
hashCode()
|
| boolean |
isBatched()
True if this request allows batching (i.e.
|
| boolean |
isFastestIntervalExplicitlySet()
This method is deprecated. Do not use. May be removed in a future
release.
|
| boolean |
isPassive()
True if the priority is
Priority.PRIORITY_PASSIVE.
|
| boolean |
isWaitForAccurateLocation()
If this request is
Priority.PRIORITY_HIGH_ACCURACY, this will delay delivery of initial
low accuracy locations for a small amount of time in case a high accuracy
location can be delivered instead.
|
| LocationRequest |
setExpirationDuration(long durationMillis)
This method is deprecated. Use
LocationRequest.Builder.setDurationMillis(long) instead. May be
removed in a future release.
|
| LocationRequest |
setExpirationTime(long elapsedRealtime)
This method is deprecated. Use
LocationRequest.Builder.setDurationMillis(long) instead. Using this
method will express the expiration time in terms of duration, which may give
unexpected results. May be removed in a future release.
|
| LocationRequest |
setFastestInterval(long fastestIntervalMillis)
This method is deprecated. Use
LocationRequest.Builder.setMinUpdateIntervalMillis(long) instead.
May be removed in a future release.
|
| LocationRequest |
setInterval(long intervalMillis)
This method is deprecated. Use
LocationRequest.Builder.setIntervalMillis(long) instead. May be
removed in a future release.
|
| LocationRequest |
setMaxWaitTime(long maxWaitTimeMillis)
This method is deprecated. Use
LocationRequest.Builder.setMaxUpdateDelayMillis(long) instead. May
be removed in a future release.
|
| LocationRequest |
setNumUpdates(int maxUpdates)
This method is deprecated. Use
LocationRequest.Builder.setMaxUpdates(int) instead. May be removed
in a future release.
|
| LocationRequest |
setPriority(int priority)
This method is deprecated. Use
LocationRequest.Builder.setPriority(int) instead. May be removed in
a future release.
|
| LocationRequest |
setSmallestDisplacement(float smallestDisplacementMeters)
This method is deprecated. Use
LocationRequest.Builder.setMinUpdateDistanceMeters(float) instead.
May be removed in a future release.
|
| LocationRequest |
setWaitForAccurateLocation(boolean waitForAccurateLocation)
This method is deprecated. Use
LocationRequest.Builder.setWaitForAccurateLocation(boolean) instead.
May be removed in a future release.
|
| String |
toString()
|
| void |
writeToParcel(Parcel parcel, int
flags)
|
This constant is deprecated.
Use
Priority.PRIORITY_BALANCED_POWER_ACCURACY instead.
This constant is deprecated.
Use
Priority.PRIORITY_HIGH_ACCURACY instead.
This constant is deprecated.
Use Priority.PRIORITY_LOW_POWER
instead.
This constant is deprecated.
Use Priority.PRIORITY_PASSIVE
instead.
This method is deprecated.
Use LocationRequest.Builder
instead. May be removed in a future release.
The duration of this request. A location request will not receive any locations
after it has expired, and will be removed shortly thereafter. A value of Long.MAX_VALUE
implies an infinite duration.
This method is deprecated.
Use
getDurationMillis() instead. Using this method will return the duration added
to the current elapsed realtime, which may give unexpected results. May be removed in a
future release.
This method is deprecated.
Use
getMinUpdateIntervalMillis() instead. May be removed in a future release.
The Granularity
of locations returned for this request. This controls whether fine or coarse locations
may be returned.
This method is deprecated.
Use
getIntervalMillis() instead. May be removed in a future release.
The desired interval of location updates. Location updates may arrive faster than
this interval (but no faster than specified by
getMinUpdateIntervalMillis()) or slower than this interval (if the request
is being throttled for example).
The maximum age of an initial historical location delivered for this request. A
value of 0 indicates that no initial historical location will be delivered, only
freshly derived locations. A value Long.MAX_VALUE
represents an effectively unbounded maximum age.
This parameter applies only to a historical location which may be delivered as the very first location for a location request. Subsequent locations will always be freshly derived, and this parameter does not apply to them.
The longest a location update may be delayed. This parameter controls location
batching behavior. If this is set to a value at least 2x larger than the interval
specified by
getIntervalMillis(), then a device may (but is not required to) save power
by delivering locations in batches. If clients do not require immediate delivery,
consider setting this value as high as is reasonable to allow for additional power
savings.
For example, if a request is made with a 2s interval and a 10s maximum update delay, this implies that the device may choose to deliver batches of 5 locations every 10s (where each location should represent a point in time ~2s after the previous).
Support for batching may vary by device type, so simply allowing batching via this parameter does not imply a client will receive batched results on all devices.
FusedLocationProviderClient.flushLocations() may be used to flush locations
that have been batched, but not delivered yet.
The maximum number of updates delivered to this request. A location request will not
receive any locations after the maximum number of updates has been reached, and will be
removed shortly thereafter. A value of Integer.MAX_VALUE
implies an unlimited number of updates.
This method is deprecated.
Use
getMaxUpdateDelayMillis() instead. May be removed in a future release.
The minimum distance required between consecutive location updates. If a derived location update is not at least the specified distance away from the previous location update delivered to the client, it will not be delivered. This may also allow additional power savings under some circumstances.
The fastest allowed interval of location updates. Location updates may arrive faster
than the desired interval (getIntervalMillis()),
but will never arrive faster than specified here. FLP APIs make some allowance for
jitter with the minimum update interval, so clients need not worry about location
updates that arrive a couple milliseconds too early being rejected.
This method is deprecated.
Use
getMaxUpdates() instead. May be removed in a future release.
The Priority
of the location request.
This method is deprecated.
Use
getMinUpdateDistanceMeters() instead.
True if this request allows batching (i.e.
getMaxUpdateDelayMillis() is at least 2x
getIntervalMillis()).
This method is deprecated.
Do not use. May be removed in a future release.
True if the priority is Priority.PRIORITY_PASSIVE.
If this request is
Priority.PRIORITY_HIGH_ACCURACY, this will delay delivery of initial low
accuracy locations for a small amount of time in case a high accuracy location can be
delivered instead.
This method is deprecated.
Use
LocationRequest.Builder.setDurationMillis(long) instead. May be removed in a
future release.
This method is deprecated.
Use
LocationRequest.Builder.setDurationMillis(long) instead. Using this method
will express the expiration time in terms of duration, which may give unexpected results.
May be removed in a future release.
This method is deprecated.
Use
LocationRequest.Builder.setMinUpdateIntervalMillis(long) instead. May be
removed in a future release.
This method is deprecated.
Use
LocationRequest.Builder.setIntervalMillis(long) instead. May be removed in a
future release.
This method is deprecated.
Use
LocationRequest.Builder.setMaxUpdateDelayMillis(long) instead. May be removed
in a future release.
This method is deprecated.
Use
LocationRequest.Builder.setMaxUpdates(int) instead. May be removed in a future
release.
This method is deprecated.
Use
LocationRequest.Builder.setPriority(int) instead. May be removed in a future
release.
This method is deprecated.
Use
LocationRequest.Builder.setMinUpdateDistanceMeters(float) instead. May be
removed in a future release.
This method is deprecated.
Use
LocationRequest.Builder.setWaitForAccurateLocation(boolean) instead. May be
removed in a future release.