getLastKnownLocation out-of-date even after other apps find my location!

In my app, I request location updates and use a LocationListener and the majority of the time everything works well. When the app starts, it uses getLastKnownLocation while waiting for the first location update.

I have been doing some tests on getLastKnownLocation and the results are strange...

If the result of getLastKnownLocation is out-of-date, then I exit the app and run Google Maps and wait for it to pick up my location, then when I re-run my app getLastKnownLocation still returns the old location. I don't understand why this is happening. Surely, if GMaps can get a fix then getLastKnownLocation should be up-to-date, right?


Asked by: Lydia840 | Posted: 25-01-2022






Similar questions

android - how to make getLastKnownLocation work on emulator

Requirement of the application is to get the lat,lon from the mobile. I want to test the samething on emulator. But getLastKnownLocation gives null value . Could you please suggest some workaround ?


getLastKnownLocation() Android, when the Last Known Location is updated?

getBestKnownLocation Returns a Location indicating the data from the last known location fix obtained from the given provider. This can be done without starting the provider. Note that this location could be out-of-date, for example if the device was turned off and moved to another location. when the Last Known Location updated in Android? is it updated if when there's an application li...


android - What does getLastKnownLocation really do?

Does it give the user's current location if the device is online? How does it determine the last known location?


android - getLastKnownLocation method always returns null

I have a problem to fixed position. I use getLastKnownLocation(LocationManager.NETWORK_PROVIDER); but always return null, i have set the permissions in your AndroidManifest.xml. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> and enabled in Settings --...


android - How reliable is LocationManager's getLastKnownLocation and how often is it updated?

I am building an app that can use a user's current location on certain actions. Location is more of a benefit to the user rather than a critical part of the process. I'm only interested in very rough accuracy and it can be off by 5 or even 10 miles and still be of value. General plan was to see if the network provider was enabled and then just do locationManager.getLastKnownLocation(LocationManager.NETW...


Android GPS getLastKnownLocation if locationUpdater takes too long

with android and using GPS as a location provider, how can I tell it to stop looking for a GPS lock after a specified number of seconds and simply resort to using the last known location instead? I am currently doing it the other way around, where I get the lask known location first, and then let the request update function run. My problem with this is that the GPS will sometimes NEVER get a fix, but it doesn't sto...


android - getLastKnownLocation(LocationManager.GPS_PROVIDER) returns NULL

I am new to Android and I am trying to write one test app which should display the latitude and longitude of the current location. Right Now, I am using Android Emulator to do so. This is the code I am using. locationManager = (LocationManager)getSystemService(context); Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); But the location object returns...


Android Google Maps - getLastKnownLocation returns inaccurate latitude and longitude

I am developing an app where I need to calculate the distance from the current position and some other locations. I am using the GPS to access the users current location and the other locations coordinates are stored in a database. The problem occurs in the following snippet: @Override public void onLocationChanged(Location arg0) { Log.v("LOCATION LAT", String.valueOf(arg0.getLatitude())); currentLo...


android - getLastknownLocation() returns null value on nexus

i am developing location based project where i am using the following code i am using google api 8 for the project lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); currloc = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); TextView t = (TextView)findViewById(R.id.textView1); try{ t.setText("Your current location is - "+currloc.getLatitude()+","+currloc...


android - getLastKnownLocation() returns null using GPS_PROVIDER

I'm making a little test program to get the hang of Android GPS, and see how the battery is effected for a school project. I simply want my device to detect my location by printing out the latitude of the last known location detected. But the location always returns null in the onResume() callback. Any help is greatly appreciated. TextView Updates; long start = -1; long battStart = -1; long stop = ...






Still can't find your answer? Check out these communities...



Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android



top