Android:SensorEvent 的 TYPE_PRESSURE 值在哪里?
我已阅读此文档 -> SensorEvent
然后,我发现为了获取 TYPE_PRESSURE 的值传感器类型,我需要监听 SensorEventListener。
问题是缺少 TYPE_PRESSURE 传感器值的文档。 有人知道吗?
更新1 我之前创建了可能与此问题相关的问题。您是否也看看这些链接:获取海拔高度值 & SensorManager.getAltitude
I've read this documentation -> SensorEvent
then, I found that in order to get the values for TYPE_PRESSURE sensor type, I need to listen for SensorEventListener.
The problem is the documentation for TYPE_PRESSURE sensor's values is missing.
Anyone knows it?
UPDATES1
I previously created questions that may relate on this matter. Would you take a look also these links: Obtain Altitude value & SensorManager.getAltitude
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我猜来自 getAltitude 参考您可以使用
SensorManager.PRESSURE_STANDARD_ATMOSPHERE
作为第一个参数。第二个参数是压力传感器给您的值。为了得到它,我还没有尝试过,我只是猜测,你可能必须注册一个 SensorEventListener 与 SensorManager .registerListener(...)。
通常,SensorEvent 对象中的值位于 event.values 属性中,因此即使没有任何文档,也要尝试查看其中存储的值。
如果您有一个可以让您做到这一点的设备,那就很容易了。
如果没有,请检查模拟器文档,其中可能包含一种触发方式ADB 压力传感器
from the getAltitude reference i guess you can use
SensorManager.PRESSURE_STANDARD_ATMOSPHERE
as first parameter.the second parameter is the value that the pressure sensor give you. To get it, i haven't tried i'm just guessing, you probably have to register a SensorEventListener with SensorManager.registerListener(...).
Normaly the values in the
SensorEvent
object are in theevent.values
attribute so even if there is not any documentation try to take a look at the values stored in there.If you have a divice that will let you do it will be easy.
if not check the emulator documentation that probably include a way to fire the pressure sensor by the ADB
我找到了 WSP 网址并发布了另一个关于如何读取结果的问题。最终,我也找到了答案。
以下是获取海平面压力值并将其作为参数传递给 SensorManager.getAltitude 的 url。
获取海上压力Level
然后,可以通过
event.values[0]
获取第二个参数AtmosphericPressure。我从@Marioo O. Lenci 的想法中想到了这个。I found the WSP url and post another question on how to read the result. Eventually, I found the answer too.
Here's the url to obtain the Pressure At Sea Level value to pass on SensorManager.getAltitude as parameter.
Obtaining Pressure At Sea Level
Then, the second parameter Atmospheric Pressure may be obtained via
event.values[0]
. I came up this from @Marioo O. Lenci 's idea.如果您指的是这个常量的值,那么它是:
它在这里定义:
android.hardware.Sensor.TYPE_PRESSURE
If you're referring to the value of this constant then it is:
It's defined here:
android.hardware.Sensor.TYPE_PRESSURE