@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_sensor_test, menu); return true; } @Override protected void onPause() { // TODO Auto-generated method stub super.onPause(); sensorManager.unregisterListener(this); // 解除监听器注册 } @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); sensorManager.registerListener(this, gyroSensor, SensorManager.SENSOR_DELAY_NORMAL); //为传感器注册监听器 } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { // TODO Auto-generated method stub
} @Override public void onSensorChanged(SensorEvent event) { // TODO Auto-generated method stub // if (event.accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) // { // return; // }