简体   繁体   English

Location.getAltitude() 在一段时间后开始返回相同的值

[英]Location.getAltitude() starts returning identical values after a certain time period

I need your help.我需要你的帮助。 I wrote a very simple Android widget that shows the altitude which I get in the onLocationChanged method:我写了一个非常简单的 Android 小部件,它显示了我在 onLocationChanged 方法中得到的高度:

public void onLocationChanged(Location location) {
    double myAltitude = -99;
    if (location.hasAltitude()) {
        myAltitude = location.getAltitude();
        Log.d("SAT-LOG","Current Altitude is : "+myAltitude);
        Log.d("SAT-LOG","Current Coordinatees : "+location.getLatitude()+"-"+location.getLongitude());
    }
    ...
}

Here how I request the location update:这里我如何请求位置更新:

locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationManager.registerGnssStatusCallback(gnssActivity);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 500, 1, gnssActivity);

I also tried this:我也试过这个:

Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setPowerRequirement(Criteria.POWER_HIGH);
criteria.setAltitudeRequired(true);
criteria.setSpeedRequired(true);
criteria.setCostAllowed(true);
criteria.setBearingRequired(false);
criteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
criteria.setVerticalAccuracy(Criteria.ACCURACY_HIGH);
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationManager.registerGnssStatusCallback(gnssActivity);
locationManager.requestLocationUpdates(1000,1,criteria,gnssActivity,null);

I noticed that location.hasAltitude() is always true.我注意到 location.hasAltitude() 总是正确的。 After 10/15 minutes the value is stuck: location.getAltitude() returns the same value until the device reboot (for the record I am using a car tablet). 10/15 分钟后,该值被卡住: location.getAltitude() 返回相同的值,直到设备重新启动(据记录,我正在使用车载平板电脑)。 Instead, the location latitude/longitude are always correct.相反,位置纬度/经度始终是正确的。 If I open the App GPSTest, I see the correct value of altitude.如果我打开 App GPSTest,我会看到正确的高度值。 Can someone help me to understand the issue?有人可以帮我理解这个问题吗? Is there a better way to get the altitude?有没有更好的方法来获得高度?

Huawei Location Kit may help with your issue.Check Docs .华为定位套件可能会帮助您解决问题。查看文档

You can obtains the altitude of the current location by using Location Kit.您可以使用 Location Kit 获取当前位置的海拔高度。

在此处输入图像描述

For Detail,pls kindly refer:详情请参考:

HWLocation 硬件位置

getAltitude() 获取海拔()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM