@Override
            public void onOrientationChanged(int orientation) {
                WindowManager localWindowManager = windowManager;
                RotationCallback localCallback = RotationListener.this.callback;
                if (windowManager != null && localCallback != null) {
                    int newRotation = localWindowManager.getDefaultDisplay().getRotation();
                    if (newRotation != lastRotation) {
                        lastRotation = newRotation;
                        localCallback.onRotationChanged(newRotation);
                    }
                }
            }
Hack to detect when screen rotation is reversed, since that does not cause a configuration change.

If it is changed through something other than the sensor (e.g. programmatically), this may not work.

See http://stackoverflow.com/q/9909037
zxing-android-embedded/src/com/journeyapps/barcodescanner/RotationListener.java