Is 'constructor LocationRequest()' deprecated in google maps v2?
Answer #1 99.1 %Yes, the LocationRequest constructor is deprecated. You can use its static method LocationRequest.create()
to create a location request.
Kotlin:
locationRequest = LocationRequest.create().apply {
interval = 100
fastestInterval = 50
priority = LocationRequest.PRIORITY_HIGH_ACCURACY
maxWaitTime = 100
}
Java:
locationRequest = LocationRequest.create()
.setInterval(100)
.setFastestInterval(3000)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
.setMaxWaitTime(100);
Update
As @Shimon pointed out LocationRequest.PRIORITY_HIGH_ACCURACY is now deprecated, so instead use Priority.PRIORITY_HIGH_ACCURACY
Answer #2 94.7 %LocationRequest.create().apply{ ... }
is now also deprecated.
Please use LocationRequest.Builder()
instead. I.E. like this:
(locationInterval
, locationFastestInterval
and locationMaxWaitTime
corresponds to the values used before when using create()
)
locationRequest = LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, locationInterval)
.setWaitForAccurateLocation(false)
.setMinUpdateIntervalMillis(locationFastestInterval)
.setMaxUpdateDelayMillis(locationMaxWaitTime)
.build()
Please read more here: https://developer.android.com/reference/android/location/LocationRequest.Builder
Answer #3 100 %This line now deprecated: priority = LocationRequest.PRIORITY_HIGH_ACCURACY
replace with priority = Priority.PRIORITY_HIGH_ACCURACY