I am trying to get both an accelerometer and orientation data. Currently, I have created AccelerometerManager and OrientationManager. They both do the same; implement SensorEventListener and get data from [] values ββin onSensorChanged () listeners.
Is there an easier way to do this? It seems that two handlers with duplicate code are not needed. Is there a way to access the values ββ[] array with a combined accelerometer and orientation data together?
Due to two handlers, I also have to do this:
orientationManager = new OrientationManager(this); orientationSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); orientationSensorManager.registerListener(orientationManager, orientationSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_GAME); accelerometerManager = new AccelerometerManager(this); accelerometerSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); accelerometerSensorManager.registerListener(accelerometerManager, orientationSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
android accelerometer orientation sensor
trinth
source share