Is there any way in Android to know device orientation change after we call setRequestedOrientation
, I have tried following ways.
getResources().getConfiguration().orientation
OrientationEventListener
Display getOrient = getWindowManager().getDefaultDisplay().getRotation();
But all the above methods are give same values even after changing the device orientation.
Can someone please suggest some way by which we can find the device orientation change after we call setRequestedOrientation
.
Might be a workaround: Handle onOrientationChanged degree from OrientationEventListener added to currente context. For example:
final OrientationEventListener orientationEventListener = new OrientationEventListener( getApplicationContext() ) {
@Override
public void onOrientationChanged( final int orientation ) {
Log.i( "orientation_test", "orientation: " + orientation );
}
};
orientationEventListener.enable();
Add and enable it at onResume and disable at onPause of Activity for example.