Android的onLocationUpdate不叫有GPS_PROVIDER [英] Android onLocationUpdate not called with GPS_PROVIDER

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

问题描述


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

Hi
I have an Android service using the location manager :

如果(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
Log.i(服务,开始利用GPS); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,LocationListener的);
}

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

然后位置监听器:

私人LocationListener的LocationListener的=新LocationListener的(){
公共无效onLocationChanged(位置aLocation){
Log.i(位置监听器,位置更新);
}
......其他的方法....
}

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

在清单中,为ACCESS_FINE_LOCATION授权设置。

In the manifest, the authorization for ACCESS_FINE_LOCATION is set.

一切工作正常无论是在模拟器和手机(的Xperia的Andr​​oid 1.6到2.2)的NETWORK_PROVIDER。它工作正常,在模拟器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.

推荐答案

这需要一段时间才能获得位置锁定。的时间到第一固定德(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 ...

下面是一个很好的文章,这将有助于你得到最好的GPS在Android手机。

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

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

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