Android onLocationUpdate not called with GPS_PROVIDER

◇◆丶佛笑我妖孽 提交于 2019-12-01 05:19:45

问题


Hi
I have an Android service using the 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 ....
}

In the manifest, the authorization for ACCESS_FINE_LOCATION is set.

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

WARN/libloc_api(1173): loc_eng_report_position: ignore position report when session status = 1

I can not see what I am missing. Any idea ? Thanks.


回答1:


It takes a while to get a location fix. The time to first fix de(TTFF) depends on a lot of factors, like number of visible GPS satellites, signal to noise ratio, the GPS chipset etc ...

Here is a nice article that will help you get the best out of GPS on android phones.



来源:https://stackoverflow.com/questions/5337333/android-onlocationupdate-not-called-with-gps-provider

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!