Your question is not clear initially.Your code and title are not matching. I am giving answer for your title only.

You have to register Location Listener for your Location Manager, then only onLocationChanged() will be called according the settings you supplied while registering location listener.

See below code how to do that. I used GPS Provider, you can use any provider based on criteria also.

LocationManger lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, new LocationListener() {
            @Override
            public void onLocationChanged(Location location) {
                // TODO Auto-generated method stub
            }
            @Override
            public void onProviderDisabled(String provider) {
                // TODO Auto-generated method stub
            }
            @Override
            public void onProviderEnabled(String provider) {
                // TODO Auto-generated method stub
            }
            @Override
            public void onStatusChanged(String provider, int status,
                    Bundle extras) {
                // TODO Auto-generated method stub
            }           
        });

Coming to your question, onLocationChanged() will be called if the current location update is not matching with last known location.

The updated location will be changed for every minTime (in my case 1000 milli sec) and also if device moved minDistance (in my case 0 meters) distance.

I hope you will understand this.

Answer from Yugandhar Babu on Stack Overflow
Top answer
1 of 3
33

Your question is not clear initially.Your code and title are not matching. I am giving answer for your title only.

You have to register Location Listener for your Location Manager, then only onLocationChanged() will be called according the settings you supplied while registering location listener.

See below code how to do that. I used GPS Provider, you can use any provider based on criteria also.

LocationManger lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, new LocationListener() {
            @Override
            public void onLocationChanged(Location location) {
                // TODO Auto-generated method stub
            }
            @Override
            public void onProviderDisabled(String provider) {
                // TODO Auto-generated method stub
            }
            @Override
            public void onProviderEnabled(String provider) {
                // TODO Auto-generated method stub
            }
            @Override
            public void onStatusChanged(String provider, int status,
                    Bundle extras) {
                // TODO Auto-generated method stub
            }           
        });

Coming to your question, onLocationChanged() will be called if the current location update is not matching with last known location.

The updated location will be changed for every minTime (in my case 1000 milli sec) and also if device moved minDistance (in my case 0 meters) distance.

I hope you will understand this.

2 of 3
7

if you want to catch new locations, you have to register a LocationListener like this:

LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
LocationListener listener = new LocationListener() {
   ...
}
locationManager.requestLocationUpdates(GPS_PROVIDER, intervall, distance, listener);

With intervall and distance you can configure:

  1. If intervall is greater than 0, the LocationManager could potentially rest for intervall milliseconds between location updates
  2. If distance is greater than 0, a location will only be broadcasted if the device moves by distance meters.

When the LocationListener is registered, the LocationManager starts to get your geo location and calls the onLocationChanged(). If the distance is very low, it can happen that the method is called very often in a short period of time. According to the intervall, the LocationManager will rest afterwards.

I think, the LocationManager will only start doing it's work, when a LocationListener is registered.

Hope that helps...

Cheers, Tobi

🌐
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() { ...
Author   mkett
🌐
Lengrand
lengrand.fr › onlocationchanged-is-never-called-on-android
onLocationChanged is never called on Android
June 23, 2025 - Criteria criteria = new Criteria(); ... something to the user. Basically, I am letting android decide which provider he wants to use (GPS or Network), and request for the last known location....
🌐
Android Developers
stuff.mit.edu › afs › sipb › project › android › docs › training › basics › location › currentlocation.html
Obtaining the Current Location | Android Developers
private final LocationListener listener = new LocationListener() { @Override public void onLocationChanged(Location location) { // A new location update is received. Do something useful with it. In this case, // we're sending the update to a handler which then updates the UI with the new // ...
🌐
Android Developers
developer.android.com › api reference › locationlistener
LocationListener | 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 · 中文 – 简体
🌐
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.
🌐
Blogger
android-er.blogspot.com › 2016 › 04 › request-location-updates-with.html
Android-er: Request Location Updates with LocationListener.onLocationChanged()
This example show how to request location auto updates, by implementing LocationListener.onLocationChanged(). To use Google Play Service in your project, you have to Add Google Play Services to Android Studio project.
Find elsewhere
🌐
GitHub
github.com › IndoorAtlas › android-sdk-examples › issues › 5
onLocationChanged wasn't called · Issue #5 · IndoorAtlas/android-sdk-examples
Hi, I enabled GPS and it works well with your app on Play store. But, with the example, we cannot get event onLocationChanged() although the onStatusChanged returns status 0.
Author   IndoorAtlas
🌐
GitHub
github.com › osmdroid › osmdroid › issues › 1765
OnLocationChanged is never triggered · Issue #1765 · osmdroid/osmdroid
January 14, 2022 - GpsMyLocationProvider gpsMyLocationProvider = new GpsMyLocationProvider(getApplicationContext()); gpsMyLocationProvider.startLocationProvider(new IMyLocationConsumer() { @Override public void onLocationChanged(Location location, IMyLocationProvider source) { Log.i("Test", "Location changed"); //THIS IS NEVER CALLED } }); MyLocationNewOverlay mapLocationOverlay = new MyLocationNewOverlay(gpsMyLocationProvider, map); mapLocationOverlay.enableFollowLocation(); mapLocationOverlay.enableMyLocation(); mapLocationOverlay.runOnFirstFix(() -> runOnUiThread(() -> { ....
Author   osmdroid
🌐
Coderanch
coderanch.com › t › 557977 › trigger-onLocationChanged-moving
is there any way to trigger onLocationChanged other than moving (Android forum at Coderanch)
I need to get current location ... trigger onLocationChanged method without changing location ? ... You will only get updates if there *is* a new location. But you will get an initial "update" with the current location no matter what. If that's not sufficient for your purposes please explain in more detail what you're trying to do. ... But you will get an initial "update" with the current location no matter what 1)How it get currentlocation without changes.Can you show with example ...
🌐
Stack Overflow
stackoverflow.com › questions › 23649612 › how-to-call-onlocationchanged-when-location-has-not-changed-with-locationclient › 23649765
android - How to call onLocationChanged when location has not changed with LocationClient? - Stack Overflow
I have successfully implemented the android location example http://developer.android.com/training/location/retrieve-current.html · I can request location updates via button click and the onLocationChanged method will be triggered to update a map view with the current location.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › android.locations.ilocationlistener.onlocationchanged
ILocationListener.OnLocationChanged(Location) Method (Android.Locations) | Microsoft Learn
[Android.Runtime.Register("onLocationChanged", "(Landroid/location/Location;)V", "GetOnLocationChanged_Landroid_location_Location_Handler:Android.Locations.ILocationListenerInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")] public void OnLocationChanged(Android.Locations.Location location); [<Android.Runtime.Register("onLocationChanged", "(Landroid/location/Location;)V", "GetOnLocationChanged_Landroid_location_Location_Handler:Android.Locations.ILocationListenerInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>] abstract member OnLocationChanged : Android.Locations.Location -> unit ·
🌐
Medium
medium.com › android-beginners › how-to-get-continuous-location-updates-in-android-9bb308d468d3
How to get continuous location updates in Android | by Velmurugan Murugesan | Howtodoandroid | Medium
March 15, 2021 - override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { val timer = Timer() LocationHelper().startListeningUserLocation( this, object : MyLocationListener { override fun onLocationChanged(location: Location?) { mLocation = location mLocation?.let { } } }) return START_STICKY } Once you received the location on service, er need to call the API from the service. To call API, I am using a retrofit API client. Please check the below link to learn more about the retrofit setup. Retrofit android example [step by step] ApiClient.kt
🌐
Support
support.indooratlas.com › support › solutions › articles › 36000051239-getting-location-updates-with-android
Getting Location Updates with Android : - Support :
private IALocationListener mIALocationListener = new IALocationListener() { // Called when the location has changed. @Override public void onLocationChanged(IALocation location) { Log.d(TAG, "Latitude: " + location.getLatitude()); Log.d(TAG, "Longitude: " + location.getLongitude()); Log.d(TAG, "Floor number: " + location.getFloorLevel()); } };...
🌐
Technobyte
technobyte.org › locationmanager-tutorial-android-studio
LocationManager Tutorial in Android
April 21, 2024 - @Override public void onLocationChanged(Location location) { tv.setText("Latitude: " + location.getLatitude() + "\nLongitude: " + location.getLongitude() + "\nAltitude: " + location.getAltitude()); } @Override public void onStatusChanged(String ...
🌐
Stack Overflow
stackoverflow.com › questions › 14795470 › how-to-use-onlocationchanged-method-in-locationlistener
android - how to use onlocationchanged method in locationlistener - Stack Overflow
May 23, 2017 - hello i'm pretty new to android.. i'm making an application which needs exact(approx 50m accuracy acceptable) user location.. i'm using locationmanager and locationlistener.. whenever i start the application i need user location returned. problem is that onlocationchanged method in locationlistener returns the latitude longitude only when they change.. how do i get user location ? locmgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, loclist_netwk); this is how i'm calling the class where i've implemented locationlistener. ... package com.example.gpsmanager; import android.app.Acti
🌐
Codepath
guides.codepath.org › android › Retrieving-Location-with-LocationServices-API
Retrieving Location with LocationServices API | Android Development | CodePath Guides
public void getLastLocation() { // Get last known recent location using new Google Play Services SDK (v11+) FusedLocationProviderClient locationClient = getFusedLocationProviderClient(this); locationClient.getLastLocation() .addOnSuccessListener(new OnSuccessListener<Location>() { @Override public void onSuccess(Location location) { // GPS location can be null if GPS is switched off if (location != null) { onLocationChanged(location); } } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.d("MapDemoActivity", "Error trying to get last GPS location"); e.printStackTrace(); } }); }