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.

Answer from Tenfour04 on Stack Overflow
🌐
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 · 中文 – 简体
🌐
Google
developers.google.com › google play services › locationrequest
LocationRequest | Google Play services | Google for Developers
October 31, 2024 - LocationRequest is used to define parameters for requesting location updates via FusedLocationProviderClient.
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.

🌐
Codepath
guides.codepath.org › android › Retrieving-Location-with-LocationServices-API
Retrieving Location with LocationServices API | Android Development | CodePath Guides
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.
🌐
Android Developers
developer.android.com › core areas › sensors and location › request location updates
Request location updates | Sensors and location | Android Developers
This document explains how to request regular updates about a device's location using the Fused Location Provider's requestLocationUpdates() method in Android.
🌐
Java Tips
javatips.net › api › com.google.android.gms.location.locationrequest
Java Examples for com.google.android.gms.location.LocationRequest
@Override public void onConnected(@Nullable Bundle bundle) { mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationRequest.setInterval(100000); if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // for ActivityCompat#requestPermissions for more details.
🌐
Medium
medium.com › @psarakisnick › android-location-manager-with-kotlin-flows-082c992d1b31
Android location manager with Kotlin flows | by Nick Psarakis | Medium
January 21, 2024 - override fun hasLocationPermission(): Boolean { return ContextCompat.checkSelfPermission( context, android.Manifest.permission.ACCESS_COARSE_LOCATION ) == PackageManager.PERMISSION_GRANTED } Then we will start with the actual function to fetch the location. ... val request = LocationRequest.Builder(Priority.PRIORITY_BALANCED_POWER_ACCURACY, TimeUnit.MINUTES.toMillis(10)) .setMinUpdateDistanceMeters(1000F) .build()
🌐
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 void checkPhoneLocationSettings( Activity activity, ActivityResultLauncher<IntentSenderRequest> locationSettingsResult, CallbackListener<Boolean> callbackListener) { LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(locationRequest); SettingsClient client = LocationServices.getSettingsClient(activity); Task<LocationSettingsResponse> task = client.checkLocationSettings(builder.build()); task.addOnSuccessListener(activity, locationSettingsResponse -> { //Location settings are fine.
Find elsewhere
🌐
Google
codelabs.developers.google.com › codelabs › while-in-use-location
Receive location updates in Android with Kotlin | Google Codelabs
March 27, 2026 - // TODO: Step 1.3, Create a LocationRequest. locationRequest = LocationRequest.create().apply { // Sets the desired interval for active location updates. This interval is inexact. You // may not receive updates at all if no location sources are available, or you may // receive them less frequently than requested. You may also receive updates more // frequently than requested if other applications are requesting location at a more // frequent interval. // // IMPORTANT NOTE: Apps running on Android 8.0 and higher devices (regardless of // targetSdkVersion) may receive updates less frequently than this interval when the app // is no longer in the foreground.
🌐
GitHub
github.com › codepath › android_guides › wiki › Retrieving-Location-with-LocationServices-API
Retrieving Location with LocationServices API · codepath/android_guides Wiki · GitHub
April 4, 2020 - private LocationRequest ... startLocationUpdates() { // Create the location request to start receiving updates mLocationRequest = new LocationRequest(); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); ...
Author   codepath
🌐
Medium
medium.com › @myofficework000 › real-time-location-tracking-made-easy-with-fused-location-provider-43de6437fbd3
Real-Time Location Tracking Made Easy with Fused Location Provider | by Abhishek Pathak | Medium
October 15, 2024 - @SuppressLint("MissingPermission") private fun startLocationUpdates() { val locationRequest = LocationRequest.create().apply { interval = 10000 // 10 seconds fastestInterval = 5000 priority = LocationRequest.PRIORITY_HIGH_ACCURACY } fusedLocationProviderClient.requestLocationUpdates(locationRequest, locationCallback, Looper.getMainLooper()) } private val locationCallback = object : LocationCallback() { override fun onLocationResult(locationResult: LocationResult) { locationResult.lastLocation?.let { location -> // Update UI with the new location binding.locationUpdate.text = "Updated Location: ${location.latitude}, ${location.longitude}" } } }
🌐
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.
🌐
Reintech
reintech.io › blog › building-location-based-android-app-google-maps-api
Building a location-based Android app with Google Maps API | Reintech media
February 4, 2026 - private void getLocationWithFallback() { fusedLocationClient.getLastLocation() .addOnSuccessListener(location -> { if (location != null) { handleLocation(location); } else { // Request fresh location update requestSingleLocationUpdate(); } }) .addOnFailureListener(e -> { // Handle location services disabled promptEnableLocation(); }); } @SuppressWarnings("MissingPermission") private void requestSingleLocationUpdate() { LocationRequest request = new LocationRequest.Builder( Priority.PRIORITY_HIGH_ACCURACY, 0) .setMaxUpdates(1) .build(); fusedLocationClient.requestLocationUpdates( request, new LocationCallback() { @Override public void onLocationResult(@NonNull LocationResult result) { handleLocation(result.getLastLocation()); } }, Looper.getMainLooper() ); }
🌐
Medium
proandroiddev.com › android-tutorial-on-location-update-with-livedata-774f8fcc9f15
Android Tutorial On Location Update With LiveData | by Mayowa Egbewunmi | ProAndroidDev
September 6, 2019 - To receive location update with FusedLocationProviderClient, we need to create LocationRequest, where we specify the interval and accuracy of the location update,
🌐
Astra Linux
opensource.hcltechsw.com › volt-mx-native-function-docs › Android › android.location-Android-10.0
android.location.LocationRequest - Documentation
android.location.LocationRequest · android.location.LocationTime · android.location.OnNmeaMessageListener · android.location.SettingInjectorService ·
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › android.locations.locationrequest
LocationRequest Class (Android.Locations) | Microsoft Learn
[<Android.Runtime.Register("android/location/LocationRequest", ApiSince=31, DoNotGenerateAcw=true)>] type LocationRequest = class inherit Object interface IParcelable interface IJavaObject interface IDisposable interface IJavaPeerable
🌐
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 · 中文 – 简体
🌐
Radar
radar.com › blog › a-guide-to-android-location-services-for-ios-developers
An Android location services tutorial for iOS developers - Radar
September 5, 2025 - private void startLocationRequest { boolean isConnected = mGoogleApiClient.isConnected(); if (!connected) { mLocationRequestPending = true; } LocationRequest locationRequest = new LocationRequest() .setInterval(30000L) // 30 seconds .setFastestInterval(5000L) // 5 seconds .setPriority(PRIORITY_BALANCED_POWER_ACCURACY); try { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, locationRequest, this); } catch (SecurityException e) { // do something } }