How to get it? In my XML file I use the only portrait orientation for my activity.
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden"
and onConfigurationChanged and does not work for orientation.
Upd currently I used:
@Override
public void onSensorChanged(SensorEvent event) {
x = event.values[0];
y = event.values[1];
}
private PictureOrientation getLastOrientation() {
MyPictureOrientation orient;
if (x >= -5 && x < 5) {
if (y > 0) {
orient = PORTRAIT;
} else {
orient = PORTRAIT_REV;
}
} else {
if (x >= -10 && x < -5) {
orient = LAND_RIGHT;
} else {
orient = LAND_LEFT;
}
}
return orient;
}