[英]Android onLocationUpdate not called with GPS_PROVIDER
Hi 你好
I have an Android service using the location manager : 我有一个使用位置管理器的Android服务:
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. 在清单中,设置了ACCESS_FINE_LOCATION的授权。
Everything works ok both in simulator and phone ( Xperia Android 1.6 to 2.2 ) for NETWORK_PROVIDER. 对于NETWORK_PROVIDER,在模拟器和手机(Xperia Android 1.6到2.2)中一切正常。 It works fine in simulator for GPS_PROVIDER.
它在GPS_PROVIDER的模拟器中工作正常。 But when I try to use the GPS in the devices, the location listener is never called.
但是当我尝试在设备中使用GPS时,从不会调用位置监听器。 I can see in the DDMS that the GPS is actually working and retrieve locations, but it never calls the listener methods.
我可以在DDMS中看到GPS实际上正在工作并检索位置,但它从不调用监听器方法。 There is a strange message though :
但有一条奇怪的信息:
WARN/libloc_api(1173): loc_eng_report_position: ignore position report when session status = 1 WARN / libloc_api(1173):loc_eng_report_position:会话状态= 1时忽略位置报告
I can not see what I am missing. 我看不出我错过了什么。 Any idea ?
任何的想法 ? Thanks.
谢谢。
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 ...
首次定位时间(TTFF)取决于很多因素,如可见GPS卫星数量,信噪比,GPS芯片组等......
Here is a nice article that will help you get the best out of GPS on android phones. 这是一篇很好的文章 ,将帮助您在Android手机上充分利用GPS。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.