How can I capture altitude on an Android phone?

删除回忆录丶 提交于 2019-12-08 07:49:06

问题


I want to be able to capture altitude in my Android app. I know I can use GPS for where I am, but is there any way I can derive roughly how high the phone is off the ground using a combination of sensors? If not, what is the closest estimation I can get?


回答1:


If the phone has a barometric pressure sensor, you can use SensorManager.getAltitude to get the altitude based on a pressure reading. This method also requires the current pressure at sea level, which can either be obtained from local airport data (via a web service) or approximated with SensorManager.PRESSURE_STANDARD_ATMOSPHERE.

For more, see:

Android: How to use SensorManager.getAltitude(float p0, float p)?



来源:https://stackoverflow.com/questions/8749719/how-can-i-capture-altitude-on-an-android-phone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!