Google
developers.google.com › google play services › locationrequest
LocationRequest | Google Play services | Google for Developers
October 31, 2024 - This method is deprecated. Use LocationRequest.Builder.setPriority(int) instead.
Program Creek
programcreek.com › java-api-examples
com.google.android.gms.location.LocationRequest#setPriority
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(1000); mLocationRequest.setFastestInterval(1000); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){ if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED){ }else{ checkLocationPermission(); } } } Example 2 ·
Java Tips
javatips.net › api › com.google.android.gms.location.locationrequest
Java Examples for com.google.android.gms.location.LocationRequest
@Override public void onConnected(Bundle bundle) { if (locationRequest == null) { locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); locationRequest.setInterval(DEFAULT_INTERVAL_MS); locationRequest.setFastestInterval(DEFAULT_FASTEST_INTERVAL_MS); } locationClient.requestLocationUpdates(locationRequest, this); }
Tabnine
tabnine.com › home › code library
Code Library - Tabnine
July 25, 2024 - Get the answers and suggestions you need from our AI code assistant. Get started in minutes with a free 90 day trial of Tabnine Pro.
Airnativeextensions
docs.airnativeextensions.com › asdocs › location › com › distriqt › extension › location › LocationRequest.html
com.distriqt.extension.location.LocationRequest
public function setPersistInBackground(persistInBackground:Boolean = true, notificationText:String = null):LocationRequest · Sets the value of persistInBackground · Parameters · Returns · See also · persistInBackground · public function setPriority(priority:int):LocationRequest ·
Android Developers
developer.android.com › api reference › locationrequest
LocationRequest | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
Android-doc
android-doc.com › reference › com › google › android › gms › location › LocationRequest.html
LocationRequest | Android Developers
Used with setPriority(int) to request the most accurate locations available.
GitHub
github.com › lostzen › lost › blob › master › lost › src › main › java › com › mapzen › android › lost › api › LocationRequest.java
lost/lost/src/main/java/com/mapzen/android/lost/api/LocationRequest.java at master · lostzen/lost
April 23, 2023 - public LocationRequest setPriority(int priority) { if (priority != PRIORITY_HIGH_ACCURACY · && priority != PRIORITY_BALANCED_POWER_ACCURACY · && priority != PRIORITY_LOW_POWER · && priority != PRIORITY_NO_POWER) { throw new IllegalArgumentException("Invalid priority: " + priority); } ·
Author lostzen
Top answer 1 of 2
3
LocationRequest locationRequest =
new LocationRequest.Builder(
LocationRequest.PRIORITY_HIGH_ACCURACY,
10000
).build();
locationRequest.setFastestInterval(5000);
2 of 2
1
locationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 100)
.setIntervalMillis(INTERVAL_MILLIS) // Sets the interval for location updates
.setMinUpdateIntervalMillis(INTERVAL_MILLIS/2) // Sets the fastest allowed interval of location updates.
.setWaitForAccurateLocation(false) // Want Accurate location updates make it true or you get approximate updates
.setMaxUpdateDelayMillis(100) // Sets the longest a location update may be delayed.
.build();
Stack Overflow
stackoverflow.com › questions › 28185208 › dynamically-change-setpriority-in-android-location-services
Dynamically Change setPriority in Android Location Services - Stack Overflow
January 6, 2017 - I have some code where a service starts the Google Play Services Location/Activity, when the Activity intent is called, I want to change the setPriority for the Location service. // Location mLocationRequest = LocationRequest.create(); if (mostProbActName.equals("still")) { mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); Log.i(TAG, "GOING TO BALANCED MODE!"); } else { mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); Log.i(TAG, "GOING TO HIGH MODE!"); }
Codepath
guides.codepath.org › android › Retrieving-Location-with-LocationServices-API
Retrieving Location with LocationServices API | Android Development | CodePath Guides
private LocationRequest ... startLocationUpdates() { // Create the location request to start receiving updates. // The no-arg LocationRequest() constructor and setPriority/setInterval/ // setFastestInterval setters are deprecated as of play-services-location 21.x — // ...
Coding-blocks-ebooks
coding-blocks-ebooks.github.io › blocks-of-android › 15-location-and-sensors › 15-1-location.html
15.1 Location API · GitBook
Link: developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#setFastestInterval(long) setPriority(int priority) - This method sets the priority of the request, which gives the Google Play services location services a strong hint about which location sources ...
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 381345 › locationrequest()-is-obsolete-and-deprecated
LocationRequest() is obsolete and deprecated - Microsoft Q&A
void CreateLocationRequest() { // mLocationRequest = new LocationRequest(); mLocationRequest = LocationRequest.Create(); mLocationRequest.SetInterval(UPDATE_INTERVAL); mLocationRequest.SetFastestInterval(FASTEST_INTERVAL); mLocationRequest.SetPriority(LocationRequest.PriorityHighAccuracy); mLocationRequest.SetSmallestDisplacement(DISPLACEMENT); locationClient = LocationServices.GetFusedLocationProviderClient(this); }
Top answer 1 of 10
138
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);
Update
As @Shimon pointed out LocationRequest.PRIORITY_HIGH_ACCURACY is now deprecated, so instead use Priority.PRIORITY_HIGH_ACCURACY
2 of 10
91
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
Huawei Developer
developer.huawei.com › consumer › en › doc › development › HMSCore-References › locationrequest-0000001050986189
LocationRequest-Class Summary-com.huawei.hms. ...
November 16, 2022 - The OpenCms demo, brought to you by Alkacon Software.
GitHub
github.com › patloew › RxLocation
GitHub - patloew/RxLocation: 🗺 [DEPRECATED] Reactive Location APIs Library for Android and RxJava 2
// Create one instance and share it RxLocation rxLocation = new RxLocation(context); LocationRequest locationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setInterval(5000); rxLocation.location().updates(locationRequest) .flatMap(location -> rxLocation.geocoding().fromLocation(location).toObservable()) .subscribe(address -> { /* do something */ });
Starred by 486 users
Forked by 92 users
Languages Java 100.0% | Java 100.0%
Tabnine
tabnine.com › home page › code › java › android.location.locationrequest
android.location.LocationRequest.setSmallestDisplacement java code examples | Tabnine
public LocationRequest buildLocationRequest() { LocationRequest locRequest = LocationRequest.create(); // Use high accuracy locRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // how often do you need to check for the location // (this is an indication, it's not exact) locRequest.setInterval(REQUIRED_INTERVAL_SEC * 1000); // if others services requires the location more often // you can still receive those updates, if you do not want // too many consider setting this lower limit locRequest.setFastestInterval(FASTEST_INTERVAL_SEC * 1000); // do you care if the user moved 1 meter?