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
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 the event.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
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.
If you're referring to the value of this constant then it is:
public static final int TYPE_PRESSURE = 6
It's defined here: android.hardware.Sensor.TYPE_PRESSURE
精彩评论