'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 1:[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);

Solution 2:[2]

For anyone who faces this error in geolocator 8.0.1 of Flutter. Try to edit FusedLocationClient.java:199 for now. Then wait for author to update the pub package

From

LocationRequest locationRequest = new LocationRequest();

To

LocationRequest locationRequest = LocationRequest.create();

This is the LocationRequest class enter image description here

Solution 3:[3]

 LocationRequest locationRequest = LocationRequest.create() //if you want access of variable
                            .setInterval(100)
                            .setFastestInterval(3000)
                            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                            .setNumUpdates(1)
                            .setMaxWaitTime(100);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Roc Boronat
Solution 2 ANDYNVT
Solution 3 Rathod Ruturaj sinh