Android的新的位置API,海拔总是0 [英] Android new location API Altitude is always zero
问题描述
我使用谷歌新的位置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屋!