[Android] How to disable the screen orientation?

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);
    }

 

posted on 2012-12-05 15:32  Jalen Wang  阅读(222)  评论(0编辑  收藏  举报

导航