Android GPS 获取高程增益和损失

Android GPS get elevation gain and loss

使用Android LocationListener我可以获得纬度、经度、速度等。但是我如何获得或计算高程增益和损失?

如果可用,您可以在 LocationListener 中获取海拔高度。请注意,这仅在使用 GPS 时可用。如果不可用,location.hasAltitude() 将为假。

public void onLocationChanged(Location location)

{   
     double lon=location.getLongitude();  
     double lat=location.getLatitude();
     double alt=location.getAltitude();  // Return altitude in meters, 0.0 if not available
     ...
}

您可以保存alt值,以便之后计算盈亏。