I'm trying to set up location updates in my Android app using com.google.android.gms:play-services-location:12.0.0
, but I'm getting the following error:
LocationRequest constructor is marked as internal and should not be accessed from apps
My location updates request looks like this:
locationClient.requestLocationUpdates(
new LocationRequest()
.setInterval(5000)
.setFastestInterval(1000)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY),
locationCallback,
null
);
I have followed the docs and the example, which do it the same way. If I'm not supposed to call new LocationRequest()
, then what is the proper way to do it?
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.
Use static method LocationRequest create (). Show activity on this post. LocationRequest initialization procedure has changed into latest Google Play Service dependencies ( > 12.0.0). Now you can use its create () method to initialize this. e.g. Show activity on this post.
All location requests are considered hints, and you may receive locations that are more/less accurate, and faster/slower than requested. Used with setPriority (int) to request "block" level accuracy.
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. This would be appropriate for mapping applications that are showing your location in real-time.
Use static methodLocationRequest create ()
.
LocationRequest locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(5000); locationRequest.setFastestInterval(1000);
LocationRequest initialization procedure has changed into latest Google Play Service dependencies ( > 12.0.0). Now you can use its create() method to initialize this. e.g.
LocationRequest request = LocationRequest.create();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With