未使用 GPS_PROVIDER 调用 Android onLocationUpdate [英] Android onLocationUpdate not called with GPS_PROVIDER

查看:23
本文介绍了未使用 GPS_PROVIDER 调用 Android onLocationUpdate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个使用位置管理器的 Android 服务:

Hi
I have an Android service using the location manager :

if(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
Log.i("服务","从 GPS 开始");locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,locationListener);
}

然后是位置监听器:

私有 LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location aLocation) {
Log.i("位置监听", "位置更新");
}
... 其他方法 ....
}

在清单中,设置了 ACCESS_FINE_LOCATION 的授权.

In the manifest, the authorization for ACCESS_FINE_LOCATION is set.

NETWORK_PROVIDER 在模拟器和手机(Xperia Android 1.6 到 2.2)中一切正常.它在 GPS_PROVIDER 的模拟器中运行良好.但是当我尝试在设备中使用 GPS 时,永远不会调用位置监听器.我可以在 DDMS 中看到 GPS 实际上正在工作并检索位置,但它从不调用侦听器方法.不过有一条奇怪的消息:

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: 当会话状态 = 1 时忽略位置报告

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.

推荐答案

获取位置修复需要一段时间.首次修复 de(TTFF) 的时间取决于很多因素,例如可见 GPS 卫星的数量、信噪比、GPS 芯片组等......

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 ...

这是一篇不错的文章,它会有所帮助您可以在 Android 手机上充分利用 GPS.

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

这篇关于未使用 GPS_PROVIDER 调用 Android onLocationUpdate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆