I know that I have to use the class OrientationListener to get the angle from the device. I want to get the angle between -90° and 90°. I don't know how to do it. picture on the left: 90 degree, picture in the middle: 0 degree and picture on the right: -90 degree
Code
class OrientationListener implements SensorEventListener
{
@Override
public void onSensorChanged(SensorEvent event)
{
angle = Math.round(event.values[2]);
if (angle < 0)
{
angle = angle * -1;
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy)
{
}
}