这是传感器测试应用的屏幕
在此应用中,重力传感器有两种类型的值:POL和RECT
在我的应用程序中,我使用它来获取重力值,但是仅获取RECT值,如何获得POL值?
var gravityX = 0f
var gravityY = 0f
var gravityZ = 0f
private val sensorListener = object: SensorEventListener {
override fun onAccuracyChanged(p0: Sensor?, p1: Int) {}
override fun onSensorChanged(event: SensorEvent?) {
if(event != null){
val sensor = event.sensor
when (sensor.type) {
Sensor.TYPE_GRAVITY -> {
gravityX = event.values[0]
gravityY = event.values[1]
gravityZ = event.values[2]
}
}
}
}
}