Android onLocationUpdate not called using GPS_PROVIDER

Hello
I have an Android service using location manager:

if(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
Log.i("service","start with GPS"); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,locationListener);
}

Then the location listener:

private LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location aLocation) {
Log.i("location listener", "location updated");
}
... other methods ....
}

Authorization for ACCESS_FINE_LOCATION is set in the manifest.

Everything works fine both in the simulator and in the phone (Xperia Android 1.6 to 2.2) for NETWORK_PROVIDER. It works great in the simulator for GPS_PROVIDER. But when I try to use GPS in devices, the location listener is never called. In DDMS, I see that GPS actually works and retrieves locations, but it never calls listener methods. However, there is a strange message:

WARN / libloc_api (1173): loc_eng_report_position: ignore location report when session state = 1

I do not see what I am missing. Any ideas? Thanks.

+4
source share
1 answer

It takes some time to get the location fix. The first correction time de (TTFF) depends on many factors, such as the number of visible GPS satellites, signal-to-noise ratio, GPS chipset, etc.

Here is a good article to help you get the best out of GPS on Android phones.

+3
source

Source: https://habr.com/ru/post/1344072/


All Articles