Below utility are got from the web:
private static int _oldScreenOrientation; public static void disableScreenOrientation() { _oldScreenOrientation = activity.getRequestedOrientation(); if(isLandscape()) activity.setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); else activity.setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } public static void restoreScreenOrientation() { activity.setRequestedOrientation(_oldScreenOrientation); }