🌐
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 · 中文 – 简体
🌐
Google
developers.google.com › google play services › locationrequest.builder
LocationRequest.Builder | Google Play services | Google for Developers
LocationRequest.Builder is used to construct a LocationRequest object · It includes constants for implicit maximum update age and minimum update interval, both set to be the same as the interval
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › android.locations.locationrequest.builder
LocationRequest.Builder Class (Android.Locations) | Microsoft Learn
A builder class for LocationRequest. [Android.Runtime.Register("android/location/LocationRequest$Builder", ApiSince=31, DoNotGenerateAcw=true)] public sealed class LocationRequest.Builder : Java.Lang.Object
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › android.locations.locationrequest.builder.build
LocationRequest.Builder.Build Method (Android.Locations) | Microsoft Learn
Builds a location request from this builder. [Android.Runtime.Register("build", "()Landroid/location/LocationRequest;", "", ApiSince=31)] public Android.Locations.LocationRequest Build();
🌐
Java Tips
javatips.net › api › com.google.android.gms.location.locationrequest
Java Examples for com.google.android.gms.location.LocationRequest
The following java examples will help you to understand the usage of com.google.android.gms.location.LocationRequest. These source code samples are taken from different open source projects. Example 1 · private void ensureLocationSettings() { LocationSettingsRequest locationSettingsRequest = new LocationSettingsRequest.Builder().addLocationRequest(LocationRequest.create().setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)).build(); RxLocationSettings.with(this).ensure(locationSettingsRequest).subscribe(new Action1<Boolean>() { @Override public void call(Boolean enabled) { Toast.makeText(MainActivity.this, enabled ?
🌐
Android Developers
developer.android.com › api reference › locationrequestcompat.builder
LocationRequestCompat.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 · 中文 – 简体
🌐
Codepath
guides.codepath.org › android › Retrieving-Location-with-LocationServices-API
Retrieving Location with LocationServices API | Android Development | CodePath Guides
mLocationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, UPDATE_INTERVAL) .setMinUpdateIntervalMillis(FASTEST_INTERVAL) .build(); // Create LocationSettingsRequest object using location request LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder(); ...
🌐
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.
Find elsewhere
🌐
DEV Community
dev.to › olubunmialegbeleye › location-services-the-android-14-maybe-15-too-way-4171
Location Services- the Android 14 (maybe 15 too) way - DEV Community
July 16, 2024 - private fun checkPhoneLocationSettings( activity: Activity, locationSettingsResult: ActivityResultLauncher<IntentSenderRequest>, callback: (Boolean) -> Unit ) { val builder = LocationSettingsRequest.Builder().addLocationRequest(locationRequest) val client = LocationServices.getSettingsClient(activity) val task = client.checkLocationSettings(builder.build()) task.addOnSuccessListener { callback(true) } task.addOnFailureListener { exception -> if (exception is ResolvableApiException) { try { locationSettingsResult.launch( IntentSenderRequest.Builder(exception.resolution).build() ) } catch (sendEx: IntentSender.SendIntentException) { // Ignore the error.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › android.locations.locationrequest.builder.-ctor
LocationRequest.Builder Constructor (Android.Locations) | Microsoft Learn
Creates a new Builder with all parameters copied from the given location request. [Android.Runtime.Register(".ctor", "(Landroid/location/LocationRequest;)V", "", ApiSince=31)] public Builder(Android.Locations.LocationRequest locationRequest);
Top answer
1 of 1
1

I haven't used location services in a long, long time, so I'm just looking at the documentation for 'LocationRequest.Builder` and guessing at your equivalent code because it looks self-explanatory. Builders are a common pattern, used more often in Java-based APIs like this one than they are used in pure-Kotlin APIs. You can look up "java builder pattern" to read about it.

private fun NewLocation() { 
    val locationRequest = LocationRequest.Builder()
        .setPriority(Priority.PRIORITY_HIGH_ACCURACY)
        .setIntervalMillis(0L)
        .setMinUpdateIntervalMillis(0L)
        .setMaxUpdates(1)
        .build()
    mfusedlocation = LocationServices.getFusedLocationProviderClient(this)
    mfusedlocation.requestLocationUpdates(locationRequest, locationCallback, Looper.myLooper())
}

FYI since you're working on a portfolio:

  • Function names in Kotlin start with a verb and lower-case letter by convention. Or if it returns a modified copy of an object, you can use a past participle instead of a phrase starting with a verb. For example, I would rename NewLocation() to something like beginLocationRequest().

  • The mSomething pattern of naming variables (putting abbreviations in front of variable names) is called Hungarian notation. m stands for "member", but Kotlin properties are not even called member variables. I've never seen Hungarian notation used in Kotlin before, and it is rarely used in Java. It is widely regarded as making code less readable, especially with modern IDEs. I would advise against using it in a portfolio project as it is more likely to damage the impression you want to give than it is to help, especially if you are using it inconsistently.

🌐
Medium
medium.com › @psarakisnick › android-location-manager-with-kotlin-flows-082c992d1b31
Android location manager with Kotlin flows | by Nick Psarakis | Medium
January 21, 2024 - @SuppressLint("MissingPermission") override fun listenToLocation(): Flow<Location> { val request = LocationRequest.Builder(Priority.PRIORITY_BALANCED_POWER_ACCURACY, TimeUnit.MINUTES.toMillis(10)) .setMinUpdateDistanceMeters(1000F) .build() return callbackFlow { if (!hasLocationPermission()) throw NoPermissionsException val locationCallback = object : LocationCallback() { override fun onLocationResult(result: LocationResult) { super.onLocationResult(result) result.lastLocation?.let { launch { send(it) } } } } }
🌐
Situm
developers.situm.com › sdk_documentation › android › javadoc › 2.3.0
LocationRequest.Builder (Situm Android SDK 2.3.0)
JavaScript is disabled on your browser · Frame Alert · This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to Non-frame version
🌐
Aiden
aiden.tr › s › sdk_car_arm64-20240307 › android-sdk_eng.root_linux-x86 › docs › reference › android › location › LocationRequest.Builder.html
LocationRequest.Builder - Android SDK | Android Developers
March 6, 2024 - Builds a location request from this builder. If an explicit minimum update interval is set, the minimum update interval of the location request will be the minimum of the interval and minimum update interval. If building a passive request then you must have set an explicit minimum update interval. public LocationRequest.Builder clearMinUpdateIntervalMillis ()