You are implementing LocationListener in your activity MainActivity. The call for concurrent location updates will therefor be like this:

mLocationClient.requestLocationUpdates(mLocationRequest, this);

Be sure that the LocationListener you're implementing is from the google api, that is import this:

import com.google.android.gms.location.LocationListener;

and not this:

import android.location.LocationListener;

and it should work just fine.

It's also important that the LocationClient really is connected before you do this. I suggest you don't call it in the onCreate or onStart methods, but in onResume. It is all explained quite well in the tutorial for Google Location Api: https://developer.android.com/training/location/index.html

Answer from HigiPha on Stack Overflow
🌐
Android Developers
developer.android.com › core areas › sensors and location › request location updates
Request location updates | Sensors and location | Android Developers
This lesson shows you how to get the update using the LocationCallback callback approach. Call requestLocationUpdates(), passing it your instance of the LocationRequest object, and a LocationCallback.
Top answer
1 of 2
40

You are implementing LocationListener in your activity MainActivity. The call for concurrent location updates will therefor be like this:

mLocationClient.requestLocationUpdates(mLocationRequest, this);

Be sure that the LocationListener you're implementing is from the google api, that is import this:

import com.google.android.gms.location.LocationListener;

and not this:

import android.location.LocationListener;

and it should work just fine.

It's also important that the LocationClient really is connected before you do this. I suggest you don't call it in the onCreate or onStart methods, but in onResume. It is all explained quite well in the tutorial for Google Location Api: https://developer.android.com/training/location/index.html

2 of 2
13

I use this one:

LocationManager.requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener)

For example, using a 1s interval:

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000,0,this);

the time is in milliseconds, the distance is in meters.

This automatically calls:

public void onLocationChanged(Location location) {
    //Code here, location.getAccuracy(), location.getLongitude() etc...
}

I also had these included in the script but didnt actually use them:

public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}

In short:

public class GPSClass implements LocationListener {

    public void onLocationChanged(Location location) {
        // Called when a new location is found by the network location provider.
        Log.i("Message: ","Location changed, " + location.getAccuracy() + " , " + location.getLatitude()+ "," + location.getLongitude());
    }

    public void onStatusChanged(String provider, int status, Bundle extras) {}
    public void onProviderEnabled(String provider) {}
    public void onProviderDisabled(String provider) {}

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000,0,this);
    }
}
🌐
Google
codelabs.developers.google.com › codelabs › while-in-use-location
Receive location updates in Android with Kotlin | Google Codelabs
March 27, 2026 - The requestLocationUpdates() call lets the FusedLocationProviderClient know that you want to receive location updates.
🌐
GitHub
github.com › mkett › android-location-listener-example
GitHub - mkett/android-location-listener-example: Example to request location changes on Android · GitHub
private val locationListener = ... fun registerToLocationListener() { ... locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 9000, 0f, locationListener ) }...
Author   mkett
🌐
Java2s
java2s.com › example › java-api › android › location › locationmanager › requestlocationupdates-4-3.html
Example usage for android.location LocationManager requestLocationUpdates
String provider = locationMana...getLastKnownLocation(provider); if (location != null) { onLocationChanged(location); } locationManager.requestLocationUpdates(provider, 20000, 0, this); } else { //GPS?????????...
🌐
Android Clarified
androidclarified.wordpress.com › 2018 › 03 › 13 › android-example-request-location-updates-with-fusedlocationproviderapi
Android Example : Request Location Updates with FusedLocationProviderApi – Android Clarified
March 13, 2018 - In our last post we developed a app to retrieve the current location of the device on Android. While retrieving the current location can be useful in a lot of real life scenarios sometimes it is just not enough. Thanks to Google's FusedLocationProviderApi receiving location change updates in ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › android.locations.locationmanager.requestlocationupdates
LocationManager.RequestLocationUpdates Method (Android.Locations) | Microsoft Learn
[Android.Runtime.Register("requestLocationUpdates", "(Ljava/lang/String;Landroid/location/LocationRequest;Landroid/app/PendingIntent;)V", "GetRequestLocationUpdates_Ljava_lang_String_Landroid_location_LocationRequest_Landroid_app_PendingIntent_Handler", ApiSince=31)] public virtual void RequestLocationUpdates(string provider, Android.Locations.LocationRequest locationRequest, Android.App.PendingIntent pendingIntent);
🌐
Google
developers.google.com › google play services › fusedlocationproviderclient
FusedLocationProviderClient | Google Play services | Google for Developers
October 31, 2024 - On the other hand, if repeated location updates are required, such as when tracking the user's location over time, requestLocationUpdates(LocationRequest, Executor, LocationListener) or one of its variants is better suited. Clients are encourage to familiarize themselves with the full range of APIs available in this class to understand which is best suited for their needs. This constant is deprecated. Use Location.isMock() on Android S and above, otherwise use LocationCompat.isMock() from the compat libraries instead.
Find elsewhere
🌐
Android Developers
minimum-viable-product.github.io › kitkat-docs › training › location › receive-location-updates.html
Receiving Location Updates | Android Developers
At this point, you can * request the current location or start periodic updates */ @Override public void onConnected(Bundle dataBundle) { // Display the connection status Toast.makeText(this, "Connected", Toast.LENGTH_SHORT).show(); // If already requested, start periodic updates if (mUpdatesRequested) { mLocationClient.requestLocationUpdates(mLocationRequest, this); } } ... } For more information about saving preferences, read Saving Key-Value Sets. To stop location updates, save the state of the update flag in onPause(), and stop updates in onStop() by calling removeLocationUpdates(LocationListener). For example:
🌐
Android Developers
developer.android.com › api reference › locationmanager
LocationManager | 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 · 中文 – 简体
🌐
GitHub
github.com › djshah17 › Location-Updates-Service-Sample
GitHub - djshah17/Location-Updates-Service-Sample
{ val binder: LocationUpdatesService.LocalBinder = service as LocationUpdatesService.LocalBinder mService = binder.service mBound = true // Check that the user hasn't revoked permissions by going to Settings. mService?.requestLocationUpdates() } override fun onServiceDisconnected(name: ComponentName?)
Starred by 6 users
Forked by 7 users
Languages   Kotlin 100.0% | Kotlin 100.0%
🌐
Google
developers.google.com › google play services › locationrequest
LocationRequest | Google Play services | Google for Developers
October 31, 2024 - For example, if a request is made with a 2s interval and a 10s maximum update delay, this implies that the device may choose to deliver batches of 5 locations every 10s (where each location should represent a point in time ~2s after the previous).
🌐
Milosev
milosev.com › home › android
Request location updates - Android - Milosev
November 30, 2025 - locationCallback = object : LocationCallback() { override fun onLocationResult(locationResult: LocationResult) { locationResult ?: return if (locationResult.locations.isNotEmpty()) { // get latest location val location = locationResult.lastLocation if (location != null) { println(location.latitude.toString()) println(location.longitude.toString()) } } } } In app\src\main\AndroidManifest.xml I have added permissions:
🌐
Program Creek
programcreek.com › java-api-examples
android.location.LocationManager#requestLocationUpdates
/** * Initialize starting values ...PS_PROVIDER); bestLocation = null; counts = 0; // turning on location updates myLocationManager.requestLocationUpdates("network", 0, 0, networkLocationListener); myLocationManager.requestLocationUpdates("gps", 0, 0, gpsLocationList...
🌐
Blogger
android-er.blogspot.com › 2016 › 04 › request-location-updates-with.html
Android-er: Request Location Updates with LocationListener.onLocationChanged()
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MY_PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION); return; } LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, this); } @Override public void onRequestPermissionsResult( int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { switch (requestCode) { case MY_PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION: { // If request is cancelled, the result arrays are empty.
🌐
Tabnine
tabnine.com › home › code library
LocationManager.requestLocationUpdates - Java
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.
🌐
Finotes Blog
blog.finotes.com › post › efficient-ways-of-using-location-services-in-kotlin-android-apps
Efficient Ways of Using Location Services in Kotlin Android Apps
July 4, 2023 - Here's an example: private val locationRequest: LocationRequest = LocationRequest.create().apply { interval = 10000 // Update interval in milliseconds fastestInterval = 5000 // Fastest update interval in milliseconds priority = LocationRequ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › android.locations.locationmanager.requestsingleupdate
LocationManager.RequestSingleUpdate Method (Android.Locations) | Microsoft Learn
[<Android.Runtime.Register("requestSingleUpdate", "(Ljava/lang/String;Landroid/app/PendingIntent;)V", "GetRequestSingleUpdate_Ljava_lang_String_Landroid_app_PendingIntent_Handler")>] abstract member RequestSingleUpdate : string * Android.App.PendingIntent -> unit override this.RequestSingleUpdate : string * Android.App.PendingIntent -> unit ... Register for a single location update using a named provider and pending intent. See #requestLocationUpdates(long, float, Criteria, PendingIntent) for more detail on how to use this method.
🌐
Medium
medium.com › @jfunkekupper › android-12-requestlocationupdates-with-pendingintents-750d8b641700
Android 12 requestLocationUpdates with PendingIntents | by Joost | Medium
October 27, 2021 - TL;DR When requesting location updates using the FusedLocationProviderClient.requestLocationUpdates() with a PendingIntent for a BroadcastReceiver, use the PendingIntent.FLAG_MUTABLE for the Intent…