Search code examples
androidkotlingoogle-maps-android-api-2google-location-services

Is 'constructor LocationRequest()' deprecated in google maps v2?


I stumbled upon this message recently, and I was pretty sure that this constructor wasn't deprecated in prior versions to 18.0.0, but I cannot find information anywhere that this one has been deprecated either.

And what should we use instead, is there another way to create a locationRequest ?

message complaining that LocationRequest() is deprecated


Solution

  • 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

    and here: https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.Builder