Android传感器各种解释

 

目前常用的有两种(小三也只有两种)

加速传感器:SENSOR_ACCELEROMETER

姿态传感器:SENSOR_ORIENTATION

 

经试验

public void onSensorChanged(int sensor, float[] values) {

里的values为如下含义;

当传感器为姿态传感器(SENSOR_ORIENTATION)时values的含义如下:

SENSOR_ORIENTATION ,  SENSOR_ORIENTATION_RAW :

All values are angles in degrees.

values[0]: Azimuth, rotation around the Z axis (0<=azimuth<360). 0 = North, 90 = East, 180 = South, 270 = West

values[1]: Pitch, rotation around X axis (-180<=pitch<=180), with positive values when the z-axis moves toward the y-axis.

values[2]: Roll, rotation around Y axis (-90<=roll<=90), with positive values when the z-axis moves toward the x-axis.

values[0] 为Yaw轴上的转动角度

values[1] 为Pitch轴上的转动角度

values[2] 为Roll轴上的转动角度

 

加传感器相应,首先在onCreate里获得系统的sensorsevice

s_sensor = (SensorManager)getSystemService(SENSOR_SERVICE);

 

 

之后再Activity类下的onResume里设定监听

 

然后,在创建监听接口

 

之后就可以根据获得的s_sensorValue去进行传感器相应啦。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值