🌐
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 · 中文 – 简体
🌐
Stack Overflow
stackoverflow.com › questions › 23886153 › android-gps-disable-updates
Android Gps Disable Updates - Stack Overflow
You can disable updates for a specific listener by calling removeUpdates method of LocationManager class. public class AndroidGPSSampleActivity extends Activity { private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1; private static ...
🌐
Stack Overflow
stackoverflow.com › questions › 40084896 › how-to-enable-and-disable-gps-updateslocationmanager-requestlocationupdates
How to enable and disable GPS updates(LocationManager.requestLocationUpdates(...)) based on a condition in Android application - Stack Overflow
//Intent service code public class MyLocationService extends IntentService { protected int runningLocationScan; GPSTracker GPSobjLM; public MyLocationService() { super("myLocationService-thread"); } @Override protected void onHandleIntent(Intent intent) { Log.d("SERVICE", "ON HANDLE INTENT"); } @Override public void onCreate() { super.onCreate(); GPSobjLM = new GPSTracker(this); if(GPSobjLM.isGPSEnabled) runningLocationScan = 1; else runningLocationScan = 0; Log.d("SERVICE", "ONCREATE"); } @Override public void onDestroy() { super.onDestroy(); if(GPSobjLM.isGPSEnabled) GPSobjLM.stopUsingGPS();
🌐
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.
🌐
DEV Community
dev.to › olubunmialegbeleye › location-services-the-android-14-maybe-15-too-way-4171
Location Services- the Android 14 (maybe 15 too) way - DEV Community
July 16, 2024 - @SuppressLint("MissingPermission") private fun requestLocationUpdate(activity: Activity) { if (isLocationPermissionGranted(activity)) { mFusedLocationProviderClient.requestLocationUpdates( locationRequest, locationCallBack, Looper.getMainLooper() ) } }
🌐
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);
    }
}
Find elsewhere
🌐
Narkive
android-developers.narkive.com › YTbYlJyZ › locationmanager-requestlocationupdates
LocationManager.requestLocationUpdates()
Post by Lance Nanek Neither version blocks. The onLocationChanged method won't even be called during the requestLocationUpdates call, only afterwards as a separate event.
🌐
Medium
medium.com › @boobalaninfo › accessing-users-location-guide-android-2023-60a6f018a718
Accessing User’s Location Guide Android 2023 | by Boobalan Munusamy | Medium
June 22, 2023 - class PiLocationException (message:String):Exception() @Singleton class PiLocationManager @Inject constructor(@ApplicationContext val context: Context) { private val fusedLocationClient: FusedLocationProviderClient by lazy { LocationServices.getFusedLocationProviderClient(context) } @SuppressLint("MissingPermission") fun locationUpdates(intervalInMillis: Long): Flow<Location> { return callbackFlow { if (!context.checkLocationPermission()) { throw PiLocationException(context.getString(R.string.missing_location_permission)) } if (!context.isNetworkOrGPSEnabled()) { throw PiLocationException(cont
🌐
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) } } }
🌐
Vanderbilt
dre.vanderbilt.edu › ~schmidt › android › android-4.0 › out › target › common › docs › doc-comment-check › reference › android › location › LocationManager.html
LocationManager | Android Developers
In case the provider is disabled by the user, updates will stop, and an intent will be sent with an extra with key KEY_PROVIDER_ENABLED and a boolean value of false.
🌐
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.
🌐
Milosev
mail.milosev.com › home › android
Request location updates
November 30, 2025 - package com.milosev.requestlocationupdates import android.Manifest import android.app.Activity import android.content.pm.PackageManager import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.os.Looper import android.view.View import androidx.core.app.ActivityCompat import com.google.android.gms.location.* class MainActivity : AppCompatActivity() { private lateinit var fusedLocationClient: FusedLocationProviderClient private lateinit var locationCallback: LocationCallback private lateinit var locationRequest: LocationRequest override fun onCreate(savedInstanceState: Bundle?)