Hello I want to use the type type_orientation
but it is deprecated for the android 4.0.3 . I use it for the augmented reality. I tried to find on the net but without success. My application works but my text inside stay in the same place! Here my code:
@Override
protected void onStart() {
super.onStart();
sensorMngr = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
sensorLstr = createListener();
sensorMngr.registerListener(sensorLstr, sensorMngr.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_UI);
}
@Override
protected void onStop() {
super.onStop();
sensorMngr = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
sensorMngr.unregisterListener(sensorLstr, sensorMngr.getDefaultSensor(Sensor.TYPE_ORIENTATION));
}
Everything it s good just this, i looked already on http://developer.android.com/reference/android/hardware/Sensor.html, but i can t understand (I m french and my english is not very perfect...) Thank you very much for your help!!!
Here's a link to a blog with a solution. Essentially, you stop using the Orientation Sensor and use the Magnetic Field Sensor and Accelerometer Sensor(s) in tandem to get equivalent functionality. It's more work but it does allow you to continue to use a callback to handle orientation changes.
The newest sensor type for this functionality is Sensor.TYPE_ROTATION_VECTOR, as shown in this Google I/O sample on slide 17:
http://commondatastorage.googleapis.com/io-2013/presentations/104%20-%20When%20Android%20Meets%20Maps%20(Final).pdf