If your app targets a newer Android version, you have to make sure to declare background permissions.

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

And make sure that the user grants background permissions to the app. Depending on the Android version of the user, you have to send them to the settings of the app in order to make this possible. See the official documentation on requesting background location permission for more information.

Answer from Stephan on Stack Overflow
🌐
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.
🌐
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.
🌐
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 ... use the PendingIntent.FLAG_MUTABLE for the Intent flag so that the provider can associate the necessary location update to the Bundle. I came across an “issue” while updating some of Google’s own outdated location samples to target the latest Android API (see the open PR here). For app security reasons, Android 12 now requires that a PendingIntent to specify its mutability through either the FLAG_IMMUTABLE or FLAG_MUTABLE flags...
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
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
🌐
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.
🌐
Stack Overflow
stackoverflow.com › questions › 71582020 › requestlocationupdates-is-not-working-on-android-11-12
locationmanager - requestLocationUpdates is not working on Android 11 & 12 - Stack Overflow
This code worked well for Android 9 and 10, but it is not working for 11 and 12. The initial location is updated but the following location is not updated at all. FINE and COARSE location permissions are requested. What could be the problem? if (!isGPSEnabled && !isNetworkEnabled) { lat = 0; lon = 0; } else { this.isGetLocation = true; // GPS if (isGPSEnabled) { locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, this); if (locationManager != null) { location = locationManager .getLastKnownLocation(LocationManager.GPS_PROVIDER); if(location != null && location.getTime()
🌐
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 - LocationRequest is used to define parameters for requesting location updates via FusedLocationProviderClient · Different scenarios may require varying request parameters, such as priority and interval, to balance accuracy and power consumption
🌐
Stack Overflow
stackoverflow.com › questions › 23159117 › android-requestlocationupdates
Android: requestLocationUpdates - Stack Overflow
Asked 12 years, 1 month ago · Modified 9 years, 6 months ago · Viewed 101 times · Part of Mobile Development Collective · 0 · I have managed to get a fix on an android device's location (both with network provider and gps provider) using: locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); but i would like calculate the phones location at the same moment once using the NETWORK_PROVIDER and then the GPS_PROVIDER so that i can compare each accuracy together.
🌐
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.
🌐
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().
🌐
DaniWeb
daniweb.com › programming › mobile-development › threads › 516044 › requestlocationupdates-does-not-work
android-development - requestLocationUpdates does not work [SOLVED] | DaniWeb
April 27, 2018 - package com.example.hp430.gpslocaction; import android.Manifest; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.provider.Settings; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Text
🌐
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
🌐
Narkive
android-developers.narkive.com › R1DoXW9N › getlastknownlocation-vs-requestlocationupdates
GetLastKnownLocation vs. requestLocationUpdates
I mentioned it filled with nostalgic for the old days of Java ME when JSR-179 was the the best alternative to build LBS apps. Having looked at the android.location pack, the best way to find the current location seems to me like that: 1. Call LocationManager.requestLocationUpdates() 2.
🌐
Milosev
milosev.com › home › android
Request location updates - Android - Milosev
November 30, 2025 - implementation 'com.google.android.gms:play-services-location:19.0.1' In onCreate I have initialized fusedLocationClient: override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) fusedLocationClient = LocationServices.getFusedLocationProviderClient(this) } I need line like · fusedLocationClient.requestLocationUpdates(locationRequest, locationCallback, Looper.getMainLooper()) For that I need locationRequest and locationCallback Both locationRequest and locationCallback I have declared as member variables: private lateinit va