当前位置: 代码迷 >> Android >> Android xyz3轴学习
  详细解决方案

Android xyz3轴学习

热度:35   发布时间:2016-05-01 18:44:27.0
Android xyz三轴学习
参照sample做了一个sensor demo
sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE);		Sensor sensor = sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);		SensorEventListener lsn = new SensorEventListener() {			public void onSensorChanged(SensorEvent e) {				x = e.values[SensorManager.DATA_X];				y = e.values[SensorManager.DATA_Y];				z = e.values[SensorManager.DATA_Z];								Tvx.setText("X轴:" + x + "");				Tvy.setText("Y轴:" + y + "");				Tvz.setText("Z轴:" + z + "");			}			public void onAccuracyChanged(Sensor s, int accuracy) {			}		};		// 注册listener,第三个参数是检测的精确度		sensorMgr				.registerListener(lsn, sensor, SensorManager.SENSOR_DELAY_GAME);
  相关解决方案