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); }
转载于:https://www.cnblogs.com/jalenwang/archive/2012/12/05/2803246.html