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.
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 - // TODO: Step 1.5, Subscribe to location changes. fusedLocationProviderClient.requestLocationUpdates(locationRequest, locationCallback, Looper.getMainLooper())
🌐
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
// See http://developer.android.com/reference/android/location/LocationManager.html locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 180000, 3, new LocationListener() { @Override public void onStatusChanged(String provider, int status, Bundle extras) { } @Override public void onProviderEnabled(String provider) { } @Override public void onProviderDisabled(String provider) { } // When the location changes, store the current location in the parent activity @Override public void onLocationChanged(Location location) { currentLocation = location; } }); // Attach the "lookup locat
🌐
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.
🌐
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 - Here we will actually request for the location */ LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, locationListener); }else Toast.makeText(this,"Connection Failed",Toast.LENGTH_SHORT).show(); break; ...
🌐
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 get the update using the LocationListener callback approach. Call requestLocationUpdates(), passing it your instance of the GoogleApiClient, the LocationRequest object, and a LocationListener.
Find elsewhere
🌐
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);
🌐
Program Creek
programcreek.com › java-api-examples
android.location.LocationManager#requestLocationUpdates
// https://developers.google.c... mContext.getSystemService(Context.LOCATION_SERVICE); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mListener); Log.d("BoundLocationMgr", "Listener added"); // Force an update with the last location, if ...
🌐
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 · 中文 – 简体
🌐
PCC
spot.pcc.edu › ~mgoodman › developer.android.com › guide › topics › location › strategies.html
Location Strategies | Android Developers
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. In order to receive location updates from NETWORK_PROVIDER or GPS_PROVIDER, you must request user permission by declaring either the ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission, respectively, in your Android manifest file. For example:
🌐
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 = LocationRequest.PRIORITY_HIGH_ACCURACY } private fun startLocationUpdates() { fusedLocationClient.requestLocationUpdates( locationRequest, locationCallback, Looper.getMainLooper() ) } private val locationCallback = object : LocationCallback() { override fun onLocationResult(locationResult: LocationResult?)
🌐
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.
🌐
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%
🌐
Java Tips
javatips.net › api › android.location.locationlistener
Java Examples for android.location.LocationListener
Example 2 · /** * Registers a listener for real locations * @param listener */ public void registerRealLocationListener(LocationListener listener) { // Check if the GPS provider exists if (myTracksLocationManager.getProvider(LocationManager.GPS_PROVIDER) == null) { listener.onProviderDisabled(LocationManager.GPS_PROVIDER); unregisterLocationListener(listener); return; } // Listen for GPS location myTracksLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, listener); // Update the listener with the current provider state if (myTracksLocationManager.isProviderEnabled(Loca
🌐
Medium
medium.com › @vjpawar9974 › implementing-foreground-service-for-location-updates-in-android-8b5fd9893189
Implementing Foreground Service for Location Updates in Android | by Viraj Pawar | Medium
November 22, 2023 - private void getLocation() { LocationRequest mLocationRequestHighAccuracy = new LocationRequest(); mLocationRequestHighAccuracy.setPriority(LocationRequest.PRIORITY_HIGH_ACCU RACY); mLocationRequestHighAccuracy.setInterval(UPDATE_INTERVAL); mLocationRequestHighAccuracy.setFastestInterval(FASTEST_INTERVAL); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Handle permission not granted } mFusedLocationClient.requestLocationUpdates(mLocationRequestHighAccuracy, new LocationCallback() { @Override public void onLocationResult(LocationResult locationResult) { Location location = locationResult.getLastLocation(); if (location != null) { double latitude = location.getLatitude(); double longitude = location.getLongitude(); // Process latitude and longitude as needed } } }, Looper.myLooper()); }
🌐
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.