Get Altitude in App Inventor

坚强是说给别人听的谎言 提交于 2019-12-23 05:25:55

问题


I'm using App Inventor. How do get altitude to work using LocationSensor? I'm using a Nexus 4 and I'm successful of getting Lat and Long.

I checked if LocationSensor.HasAltitude and it returned false.


回答1:


Download and install Sensor Kinetics on your device from Google Play. The app will tell you what your device supports, or doesn't support.

See the App Inventor Documentation that confirms that the altitude has to be supported by your device for it work.

My LG G2 phone for instance, which is better than the Nexus 5 hardware-wise, has gps (although Sensor Kinetics doesn't mention the gps), a gyroscope sensor, a magnetometer, a gravity sensor, and a bunch of other sensors, but it does not have a pressure sensor, nor an ambient temperature sensor. So the only way I could tell my altitude is by inferring my altitude from my gps location on a map with altitude data (although, this obviously wouldn't give me an accurate reading if I went up the floors in a building, or went up and down in an helicopter).

One device that has a pressure sensor (that I can remember seeing the demo of) is the Xoom. Apparently, its pressure sensor is quite sensitive (although, that information would have to be coupled with a temperature sensor, or current meteorical/geo information, to be able to compute an accurate altitude, and that sensor would give you a false altitude result in a plane's passenger compartment that's pressurized).




回答2:


make sure, gps is enabled on your device and gps is available as provider, then set LocationSensor.ProviderName = gps, also lock the provider: LocationSensor.ProviderLocked = true

this snippet might help http://puravidaapps.com/snippets1.php#gps



来源:https://stackoverflow.com/questions/21440823/get-altitude-in-app-inventor

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