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 document explains how to request regular updates about a device's location using the Fused Location Provider's requestLocationUpdates() method in Android.
🌐
Google
developers.google.com › google play services › fusedlocationproviderclient
FusedLocationProviderClient | Google Play services | Google for Developers
October 31, 2024 - The getCurrentLocation(CurrentLocationRequest, CancellationToken) API is designed with exactly this use case in mind. 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.
🌐
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.
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);
    }
}
🌐
Android Developers
minimum-viable-product.github.io › marshmallow-docs › training › location › receive-location-updates.html
Receiving Location Updates | Android Developers
This lesson shows you how to request regular updates about a device's location using the requestLocationUpdates() method in the fused location provider.
🌐
Android Developers
developer.android.com › core areas › sensors and location › get the last known location
Get the last known location | Sensors and location | Android Developers
This is the recommended way to get a fresh location, whenever possible, and is safer than alternatives like starting and managing location updates yourself using requestLocationUpdates().
🌐
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 · 中文 – 简体
Find elsewhere
🌐
Java Tips
javatips.net › api › android.location.locationlistener
Java Examples for android.location.LocationListener
LocationManager.NETWORK_PROVIDER : LocationManager.GPS_PROVIDER; manager.requestLocationUpdates(provider, 0, 0, new LocationListener() { @Override public void onLocationChanged(Location location) { if (success != null) { success.onFinished(location.getLatitude(), location.getLongitude()); } manager.removeUpdates(this); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { Logger.d(provider); } @Override public void onProviderEnabled(String provider) { Logger.d(provider); } @Override public void onProviderDisabled(String provider) { Logger.d(provider); } }); }
🌐
PCC
spot.pcc.edu › ~mgoodman › developer.android.com › guide › topics › location › strategies.html
Location Strategies | Android Developers
To request location updates from the GPS provider, substitute GPS_PROVIDER for NETWORK_PROVIDER. You can also request location updates from both the GPS and the Network Location Provider by calling requestLocationUpdates() twice—once for NETWORK_PROVIDER and once for GPS_PROVIDER.
🌐
Java2s
java2s.com › example › java-api › android › location › locationmanager › requestlocationupdates-4-3.html
Example usage for android.location LocationManager requestLocationUpdates
String provider = locationManager.getBestProvider(criteria, true); // ??? Location location = locationManager.getLastKnownLocation(provider); if (location != null) { onLocationChanged(location); } locationManager.requestLocationUpdates(provider, 20000, 0, this); } }
🌐
Fritz ai
fritz.ai › home › blog › handling location data in android
Handling Location Data in Android - Fritz ai
September 21, 2023 - ... try { fusedLocationProviderClient.requestLocationUpdates( locationRequest, locationCallback, Looper.myLooper()) } catch (se: SecurityException) { Log.e(TAG, "Lost location permissions. Couldn't remove updates. $se") //Create a function to request necessary permissions from the app.
🌐
Medium
medium.com › @huseyin_37353 › best-way-to-get-location-on-android-72695fef17a4
Best and Trustworthy Way to Get Location on Android | by Hüseyin Bülbül | Medium
October 16, 2020 - { locationResult?.lastLocation?.let { haveNewLocation(it) } } } locationRequest = LocationRequest() locationRequest?.apply { priority = LocationRequest.PRIORITY_HIGH_ACCURACY interval = 5000 } client?.let { val hasFineLocationPermission = ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) val hasCoarseLocationPermission = ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) if(hasFineLocationPermission == PackageManager.PERMISSION_GRANTED && hasCoarseLocationPermission == PackageManager.PERMISSION_GRANTED) { it.requestLocationUpdates(locationRequest, callback, null) } } }
🌐
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 = object : LocationListener { override fun onLocationChanged(location: Location) { ... } } private fun registerToLocationListener() { ... locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 9000, 0f, locationListener ) }
Author   mkett
🌐
Narkive
android-developers.narkive.com › YTbYlJyZ › locationmanager-requestlocationupdates
LocationManager.requestLocationUpdates()
Permalink Hi, Using LocationManager to get location updates: LocationManager.requestUpdates( String provider, long minTime, float minDistance, LocationListener listener); If our main UI thread registers the LocationListener, will it get blocked whenever the service is trying to get a fix?: public class MyActivvity { public void onCreate() { super.onCreate(); LocationManager manager = getSystemService(Context.LOCATION_SERVICE); manager.requestLocationUpdates(..., new LocationListener() { public void onLocationChanged(Location location) { // is this going to block?
🌐
MapLibre
maplibre.org › maplibre-native › android › api › -map-libre -native -android › org.maplibre.android.location.engine › -location-engine-proxy › request-location-updates.html
requestLocationUpdates
open fun requestLocationUpdates(@NonNull request: LocationEngineRequest, @NonNull callback: LocationEngineCallback<LocationEngineResult>, @Nullable looper: Looper)