Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 984
Roar Grønmo Avatar asked Mar 05 '21 09:03

Roar Grønmo


People also ask

What is LocationRequest in android?

public final class LocationRequest extends Object. implements Parcelable. An encapsulation of various parameters for requesting location through FusedLocationProviderClient .

What is setFastestInterval?

setFastestInterval(long) means - if a location is available sooner you can get it (i.e. another app is using the location services).

Is the locationrequest constructor deprecated in Java?

Yes, the LocationRequest constructor is deprecated. You can use its static method LocationRequest.create () to create a location request. Ahh !! Very good ! From which version was this one introduced ? I think after version 18.0.0 constructor was deprecated.

Is there another way to create a locationrequest?

And what should we use instead, is there another way to create a locationRequest ? Yes, the LocationRequest constructor is deprecated. You can use its static method LocationRequest.create () to create a location request. Ahh !! Very good ! From which version was this one introduced ?

Is mlocationrequest() obsolete?

LocationRequest() is obsolete and deprecated I was building my Geolocation Xamarin App and recently found out upon trying to create a "mLocationRequest = new LocationRequest()" that LocationRequest() has been deprecated. Does anyone know how or what code to replace it with? dotnet-xamarin Comment Comment · Show 15 Comment

What is the use of location request object?

LocationRequest objects are used to request a quality of service for location updates from the FusedLocationProviderApi. For example, if your application wants high accuracy location it should create a location request with setPriority (int) set to PRIORITY_HIGH_ACCURACY and setInterval (long) to 5 seconds.


2 Answers

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); 
like image 109
Kunu Avatar answered Sep 21 '22 10:09

Kunu


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

like image 34
ANDYNVT Avatar answered Sep 17 '22 10:09

ANDYNVT