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
๐ŸŒ
DaniWeb
daniweb.com โ€บ programming โ€บ mobile-development โ€บ threads โ€บ 516044 โ€บ requestlocationupdates-does-not-work
android-development - requestLocationUpdates does not work [SOLVED] | DaniWeb
April 27, 2018 - It is working perfectly. But now i want to take location updates. For this i implemented LocationListener interface . I overridded the metod On location Change, but when i run the application, this method does not respond in any way. There is no error, no exception and no response I have attached my code. Please check it and guide me ยท package com.example.hp430.gpslocaction; import android...
๐ŸŒ
Android Developers
developer.android.com โ€บ core areas โ€บ sensors and location โ€บ request location updates
Request location updates | Sensors and location | Android Developers
Before requesting location updates, your app must connect to location services and make a location request. The lesson on Changing Location Settings shows you how to do this. Once a location request is in place you can start the regular updates by calling requestLocationUpdates().
๐ŸŒ
Google
developers.google.com โ€บ google play services โ€บ fusedlocationproviderclient
FusedLocationProviderClient | Google Play services | Google for Developers
October 31, 2024 - This API has the same background location limits that apply to requestLocationUpdates(LocationRequest, PendingIntent) and all location APIs, so clients may note that this API fails to return a location more often when invoked from the background.
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);
    }
}
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 60809527 โ€บ the-requestlocationupdates-to-get-gps-not-work
android - The requestLocationUpdates to get GPS not work - Stack Overflow
I am new to Android and try to have one example to get GPS location. I surf through the web and have following code. The program will crash once I click the button to get a GPS. I found it seems something wrong when I call locationManager.requestLocationUpdates(commandStr, 1000, 0, locationListener); I trace it into requestLocationUpdates and found it crashed at Looper class ยท
๐ŸŒ
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.
Find elsewhere
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 69507450 โ€บ requestlocationupdates-not-working-on-emulator
android - requestLocationUpdates not working on emulator - Stack Overflow
LocationServices.getFusedLocationProviderClient(getApplication()).removeLocationUpdates(lcb); //x,y ์ขŒํ‘œ๋กœ ๋ณ€ํ™˜ gpt.transfer(gpt,0); Log.d(TAG, gpt.toString()); setGeoInfo(gpt); //๋ณ€ํ™˜๋œ ์ •๋ณด๋ฅผ GeoInfo์— ๋„ฃ์Œ mldGi.setValue(gi); } }; } @SuppressLint("MissingPermission")//์œ„์น˜๊ถŒํ•œ ์ฒดํฌ์•ˆํ•ด๋„ ๋œ๋‹ค๊ณ  ํ•˜๋Š” ๋ถ€๋ถ„ ์•ˆํ•˜๋Š” ์ด์œ ๋Š” SplashActivity์—์„œ ์ด๋ฏธ ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. public void requestUpdate(LocationRequest locationRequest){ Log.d(TAG,"LocationRequest have been request"); mldGi = new MutableLiveData<GeoInfo>(); requestLocationUpdate = true; LocationServic
๐ŸŒ
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()
๐ŸŒ
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); //provider?????????????? if (provider != null) { Toast.makeText(this, provider + "???", Toast.LENGTH_LONG).show(); Log.d("app", "the best provider is " + provider); // ??? Location location = locationManager.getLastKnownLocation(provider); if (location != null) { onLocationChanged(location); } locationManager.requestLocationUpdates(provider, 20000, 0, this); } else { //GPS????????? Toast.makeText(this, "????????", Toast.LENGTH_LONG).show(); } } } From source file:it.geosolutions.geocollect.android.core.mission.PendingMissionListActivity.java
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ dotnet โ€บ api โ€บ android.locations.locationmanager.requestlocationupdates
LocationManager.RequestLocationUpdates Method (Android.Locations) | Microsoft Learn
Note: Since Android KitKat, Criteria requests will always result in using the #FUSED_PROVIDER. See #requestLocationUpdates(String, long, float, PendingIntent) for more detail on how this method works.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 15821653 โ€บ requestlocationupdates-not-working-for-service
android - requestLocationUpdates not working for Service - Stack Overflow
@Mugen, nope you can definitely call requestLocationUpdates from a background service. I would read up on service lifecycle and thread handling, my guess is your service is probably starting, and then just stopping... again back to my answer above. ... When calling this code from the Activity that is currently running, the myLocationListenerInstance is getting a notification in less than TIMEOUT seconds.
๐ŸŒ
Google
codelabs.developers.google.com โ€บ codelabs โ€บ while-in-use-location
Receive location updates in Android with Kotlin | Google Codelabs
March 27, 2026 - Everything should work as it did before, but now it works on Android 10. If you didn't accept the permissions for locations before, you should now see the permission screen! Note: If you have already accepted permissions, you won't see the new dialog for location permissions.
๐ŸŒ
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:
๐ŸŒ
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 ...
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 23159117 โ€บ android-requestlocationupdates
Android: requestLocationUpdates - Stack Overflow
I have managed to get a fix on ... using: locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);...
๐ŸŒ
Google
developers.google.com โ€บ google play services โ€บ locationrequest
LocationRequest | Google Play services | Google for Developers
October 31, 2024 - For example, clients that are showing the user's location in realtime may consider a Priority.PRIORITY_HIGH_ACCURACY request with a short interval. At the other extreme, a client that wants a negligible power impact while still receiving opportunistic locations could use a Priority.PRIORITY_PASSIVE request so that the client will not trigger any location updates, but can still receive locations updates triggered by other client's location requests.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 25352490 โ€บ android-do-not-know-why-requestlocationupdate-not-working-on-my-phone
google maps - android do not know why requestLocationUpdate not working on my phone - Stack Overflow
gmap = ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map)).getMap(); gmap.setMyLocationEnabled(true); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mLocationManager.requestLocationUpdates...