locationmanager
How to stop location manager?
You should call the method removeUpdates inside the method onPause: @Override protected void onPause() { super.onPause(); locationManager.removeUpdates(this); Log.i(TAG, “onPause, done”); }
GPS Android – get positioning only once
Dont use the getLastKnownLocation because that could be returning null or old data. This code Only fetches the location once a button is pressed and not every time. People use to leave the location listener listen in every instance and that kills the battery life so Use the code snippet I have posted by doing … Read more
LocationListener of NETWORK_PROVIDER is enabled but , onLocationChanged is never called
i have experienced similar issues with Network provider and only solution was force device restart. Though google map was showing always correct location, because it uses other sensors information also apart from Network location provider. But here is good news, not Long time back Google introduced Fused Location Provider api’s via its Google Play Service … Read more
NETWORK_PROVIDER not providing updated locations
I finally found a way to solve this problem (see my question here). In my case on S3 Galaxy Mini there were similar symptoms (no location updates until reboot…) like the ones described above. Location in most cases stopped updating when the device reached low power conditions, but sometimes it just happened even when the … Read more
OnLocationChanged callback is never called
It looks like you setup should work, since it doesn’t, I would make your example as simple as possible in order to troubleshoot. I would make your request look like requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); This way you get ALL the updates possible. And comment out the part about getting the last … Read more
Difference between LocationRequest setInterval (long millis) and LocationRequest setFastestInterval (long millis)
Based on the relevant Android documentation: setInterval(long) means – set the interval in which you want to get locations. setFastestInterval(long) means – if a location is available sooner you can get it (i.e. another app is using the location services). For example, you start your application and register it via setInterval(60*1000), that means that you’ll … Read more
Android check permission for LocationManager
With Android API level (23), we are required to check for permissions. https://developer.android.com/training/permissions/requesting.html I had your same problem, but the following worked for me and I am able to retrieve Location data successfully: (1) Ensure you have your permissions listed in the Manifest: <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION” /> <uses-permission android:name=”android.permission.ACCESS_COARSE_LOCATION”/> (2) Ensure you request permissions from the … Read more