Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android LocationRequest is private

Tags:

java

android

I want to get driver current location in uber clone. When I write this code:

locationRequest=LocationRequest.create();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(5000);
locationRequest.setFastestInterval(1000);

I get the error:

Cannot resolve method 'create' in 'LocationRequest'

And when I write

mLocationRequest=new LocationRequest();

I get this error:

'LocationRequest()' has private access in 'android.location.LocationRequest'

num 1

num 2

like image 867
Paradox Api Avatar asked Oct 31 '25 18:10

Paradox Api


1 Answers

LocationRequest.Builder works with 1 or 2 parameters. This is the code that worked for me :

 mLocationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 1000)
                .setWaitForAccurateLocation(false)
                .setMinUpdateIntervalMillis(500)
                .setMaxUpdateDelayMillis(1000)
                .build();
like image 161
Anatolii Bivol Avatar answered Nov 03 '25 08:11

Anatolii Bivol