Android的新的位置API,海拔总是0 [英] Android new location API Altitude is always zero

查看:719
本文介绍了Android的新的位置API,海拔总是0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用谷歌新的位置API在我的应用程序是这样

I am using Google new location Api in my app like this

private static final LocationRequest REQUEST = LocationRequest.create().setInterval(2000).setFastestInterval(1000)
        .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

private LocationListener mLocationListener = new LocationListener() {

    @Override
    public void onLocationChanged(final Location location) {
        if(location.hasAltitude()){
            Log.e(TAG, "Altitude " + location.getAltitude());
        }else{
            Log.e(TAG, "Location does not have altitude");
        }
    }
};

location.hasAltitude()总是假的,我已经测试它真实的设备,并在开放的领域,但它没有任何地方海拔高度,但如果我使用老位置监听器,它的做工精细,

but location.hasAltitude() always false, I have tested it on real device and in open area, but it does not have altitude anywhere, but if I am using the old location Listener, its working fine,

推荐答案

由于3.1.36版本的API融合位置提供的始终返回false有(至少对我来说,当已经开启GPS),所以你可能要坚持使用的LocationManager 和GPS提供商。

As of 3.1.36 version of the API fused location provider always returns false there (at least for me when having GPS turned on), so you may want to stick with LocationManager and GPS provider.

希望他们将改善未来的版​​本融合算法。

Hopefully they will improve the fused algorithm in the future release.

这篇关于Android的新的位置API,海拔总是0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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