For me, it was because I used the wrong import.
Try using the right one:
import com.google.android.gms.location.LocationRequest;
Answer from LANAH PHENG on Stack OverflowMedium
tomas-repcik.medium.com › locationrequest-create-got-deprecated-how-to-fix-it-e4f814138764
LocationRequest.create() got deprecated. How to fix it? | by Tomáš Repčík | Medium
October 30, 2022 - Fields of LocationRequest used to be filled upon the creation of the LocationRequest. However, new setters are used by the new Builder of the LocationRequest. LocationRequest.PRIORITY_HIGH_ACCURACY and other values are deprecated too. LocationRequest.Builder(timeInterval) — time in milliseconds, how often you want to get location updates · LocationRequest.Builder(Priority, timeInterval) — same as above + priority, which now has a separate interface with the same values as before
Stack Overflow
stackoverflow.com › questions › 78039846 › cannot-resolve-method-create-in-locationrequest
java - Cannot resolve method 'create' in 'LocationRequest' - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... locationRequest=LocationRequest.create(); //create() function is not identify and i am using the latest version com.google.android.gms:play-services-location:21.1.0 and but still getting this error please solve my query.
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.
Codepath
guides.codepath.org › android › Retrieving-Location-with-LocationServices-API
Retrieving Location with LocationServices API | Android Development | CodePath Guides
You can remove ACCESS_FINE_LOCATION this will still work with less precision. Note: The permissions model has changed starting in Marshmallow. If your targetSdkVersion >= 23 and you are running on a Marshmallow (or later) device, you may need to enable runtime permissions. You can also read more about the runtime permissions changes here. Inside an Activity, put the following to connect and start receiving location updates: private LocationRequest mLocationRequest; private long UPDATE_INTERVAL = 10 * 1000; /* 10 secs */ private long FASTEST_INTERVAL = 2000; /* 2 sec */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); startLocationUpdates(); } // Trigger new location updates at interval protected void startLocationUpdates() { // Create the location request to start receiving updates.
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();
Android Developers
developer.android.com › api reference › locationrequest.builder
LocationRequest.Builder | 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 · 中文 – 简体
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); } ... Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Java Tips
javatips.net › api › com.google.android.gms.location.locationrequest
Java Examples for com.google.android.gms.location.LocationRequest
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 1. setContnetView setContentView(R.layout.activity_main); // 2. get reference to TextView txtLong = (TextView) findViewById(R.id.txtLong); txtLat = (TextView) findViewById(R.id.txtLat); // 3. create LocationClient mLocationClient = new LocationClient(this, this, this); // 4. create & set LocationRequest for Location update mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); // Set the update interval to 5 seconds mLocationRequest.s
GitHub
github.com › Baseflow › flutter-geolocator › issues › 1206
LocationRequest deprecated · Issue #1206 · Baseflow/flutter-geolocator
January 31, 2023 - ...\Pub\Cache\hosted\pub.dartlang.org\geolocator_android-4.1.7\android\src\main\java\com\baseflow\geolocator\location\FusedLocationClient.java:86: warning: [deprecation] create( ) in LocationRequest has been deprecated LocationRequest locationRequest = LocationRequest.create(); ^ ...\Pub\Cache\hosted\pub.dartlang.org\geolocator_android-4.1.7\android\src\main\java\com\baseflow\geolocator\location\FusedLocationClient.java:89: warning: [deprecation] setPrio rity(int) in LocationRequest has been deprecated locationRequest.setPriority(toPriority(options.getAccuracy())); ^ ...\Pub\Cache\hosted\pub.d
Author Baseflow
Top answer 1 of 2
73
Use static methodLocationRequest create ().
LocationRequest locationRequest = LocationRequest.create();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(5000);
locationRequest.setFastestInterval(1000);
2 of 2
15
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();
Stack Overflow
stackoverflow.com › questions › 61860833 › requestlocationupdates-doesnt-call-the-locationcallback
android - requestLocationUpdates doesn't call the locationCallback - Stack Overflow
{ finish(); } }).show() } ... is working!") } } if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { println("This app hasn't permission to access users location") return; } val locationRequest = LocationRequest.create() val fifteen ...
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 Developers
developer.android.com › core areas › sensors and location › change location settings
Change location settings | Sensors and location | Android Developers
The following code snippet shows how to determine whether the user's location settings allow location services to create a LocationRequest, as well as how to ask the user for permission to change the location settings if necessary: task.addOnSuccessListener { locationSettingsResponse -> // All location settings are satisfied. The client can initialize // location requests here. // ... } task.addOnFailureListener { exception -> if (exception is ResolvableApiException){ // Location settings are not satisfied, but this can be fixed // by showing the user a dialog.
GitHub
github.com › mcharmas › Android-ReactiveLocation › issues › 43
Location updates not working when WiFi is enabled. · Issue #43 · mcharmas/Android-ReactiveLocation
Notifications · Fork 319 · Star 2.1k · New issue · Jump to bottom · Closed · 2bard opened this issue · May 8, 2015 · 3 comments · Closed · 2bard opened this issue · May 8, 2015 · 3 comments · Copy link · Apologies if i'm doing something wrong here. I'm subscribing for location updates but I only get the updates when wifi is turned off · My code: LocationRequest request = LocationRequest.create() //standard GMS LocationRequest .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setSmallestDisplacement(0.1f) .setNumUpdates(5) .setInterval(100); Subscription subscription = locationProvider.getUpdatedLocation(request) .subscribe(new Action1<Location>() { @Override public void call(Location location) { //do stuff } }); As soon as I disable wifi I start receiving the updates.
Author mcharmas