LocationManager locationManager = (LocationManager)getApp().getSystemService(Context.LOCATION_SERVICE); //getApp() returns my Application object
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER , 1, 1, this);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1, 1, this);
That's the code I'm using to listen. With GPS enabled, everything works fine. However, if I disable GPS and rely on network location, it gives me stale results -- in this case, from two days ago. I cannot get it to update. Calling getLastKnownLocation returns the same stale results.
Google Maps updates just fine, so I know it's not a hardware/system configuration problem.
I've Googled around, and found a few people with similar problems, but no answers. I've tried targeting my project to API level 8 (2.2) as well as 15 (4.0.3). Same results. My phone is running ICS.
I've also tried removing the request for GPS_PROVIDER, as well as including requests for everything in getAllProviders(). Same deal.
Any idea why NETWORK_PROVIDER is not updating? Any help would be greatly appreciated.
(P.S. No, I don't I normally use "1, 1" as my time/distance parameters; I just changed it while debugging this.)
EDIT: I forgot to mention that yes, isProviderEnabled() returns true.
Galaxy S4
. I am only usingNETWORK_PROVIDER
in my code. I can tell that my app is using a location on the way back from an out of town trip. Perhaps the provider's behavior changes as the battery gets low but then doesn't recover after charging? I'd really like to avoid usingPlay
since one of my requirements is to support theKindle
. – Secondrate