Android 新位置 API 海拔高度始终为零

标签 android google-maps location

我在我的应用程序中使用 Google 新位置 Api,如下所示

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() 总是 false,我已经在真实设备和开放区域中测试了它,但它在任何地方都没有海拔高度,但如果我使用旧的位置监听器,它的工作正常,

最佳答案

从 3.1.36 版本开始,API 融合位置提供程序始终返回 false(至少对于我来说,当打开 GPS 时),因此您可能需要坚持使用 LocationManager 和 GPS 提供程序。

希望他们能够在未来的版本中改进融合算法。

关于Android 新位置 API 海拔高度始终为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16894247/

相关文章:

javascript - 为什么谷歌地图在网站上不起作用?

ios - 在标记 swift 下方添加永久标签

android - 查找用户停放汽车的位置 Android

flutter - 使用 Flutter 打开 GPS

java - 在空对象引用上调用虚拟方法 'double android.location.Location.getLatitude()' 时出错

android - 自定义 FragmentTabHost 在底部设置 TabWidget

android - 在 Proguard 中保留带注释的类

android - 我应该使用什么进行实时地理编码 : Google APIs or Android APIs?

android - 如何设置按钮不可见android

android - 从 quickblox android 下载图像