當前位置: 首頁>>代碼示例>>Java>>正文


Java Activity.getRequestedOrientation方法代碼示例

本文整理匯總了Java中android.app.Activity.getRequestedOrientation方法的典型用法代碼示例。如果您正苦於以下問題:Java Activity.getRequestedOrientation方法的具體用法?Java Activity.getRequestedOrientation怎麽用?Java Activity.getRequestedOrientation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.getRequestedOrientation方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: callActivityOnCreate

import android.app.Activity; //導入方法依賴的package包/類
@Override
public void callActivityOnCreate(Activity activity, Bundle icicle) {
    VirtualCore.get().getComponentDelegate().beforeActivityCreate(activity);
    IBinder token = mirror.android.app.Activity.mToken.get(activity);
    ActivityClientRecord r = VActivityManager.get().getActivityRecord(token);
    if (r != null) {
        r.activity = activity;
    }
    ContextFixer.fixContext(activity);
    ActivityFixer.fixActivity(activity);
    ActivityInfo info = null;
    if (r != null) {
        info = r.info;
    }
    if (info != null) {
        if (info.theme != 0) {
            activity.setTheme(info.theme);
        }
        if (activity.getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
                && info.screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
            activity.setRequestedOrientation(info.screenOrientation);
        }
    }
    super.callActivityOnCreate(activity, icicle);
    VirtualCore.get().getComponentDelegate().afterActivityCreate(activity);
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:27,代碼來源:AppInstrumentation.java

示例2: callActivityOnCreate

import android.app.Activity; //導入方法依賴的package包/類
@Override
public void callActivityOnCreate(Activity activity, Bundle icicle) {
       VirtualCore.get().getComponentDelegate().beforeActivityCreate(activity);
	IBinder token = mirror.android.app.Activity.mToken.get(activity);
	ActivityClientRecord r = VActivityManager.get().getActivityRecord(token);
	if (r != null) {
           r.activity = activity;
       }
	ContextFixer.fixContext(activity);
	ActivityFixer.fixActivity(activity);
	ActivityInfo info = null;
	if (r != null) {
           info = r.info;
       }
	if (info != null) {
           if (info.theme != 0) {
               activity.setTheme(info.theme);
           }
           if (activity.getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
                   && info.screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
               activity.setRequestedOrientation(info.screenOrientation);
           }
       }
	super.callActivityOnCreate(activity, icicle);
	VirtualCore.get().getComponentDelegate().afterActivityCreate(activity);
}
 
開發者ID:codehz,項目名稱:container,代碼行數:27,代碼來源:AppInstrumentation.java

示例3: switchOrientation

import android.app.Activity; //導入方法依賴的package包/類
public void switchOrientation(Activity activity) {
    Log.d(TAG, "[switchOrientation]");
    if (activity.getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}
 
開發者ID:axlecho,項目名稱:tuxguitar,代碼行數:9,代碼來源:ScreenManager.java

示例4: GyroViewListener

import android.app.Activity; //導入方法依賴的package包/類
/**
 * Creates a new GyroViewListener
 *
 * @param activity containing the views to orient.
 * @param rate at which sensor events are processed (see also
 * {@link SensorManager SensorManager}). Use the default
 * value of {@link SensorManager#SENSOR_DELAY_NORMAL
 * SENSOR_DELAY_NORMAL} for simple screen orientation change detection.
 *
 * @throws IllegalStateException
 */
public GyroViewListener(Activity activity, int rate) throws IllegalStateException {
    super(activity, rate);
    mOrientation = activity.getRequestedOrientation();

    // Activity must have orientation set with a static orientation
    // in the manifest
    if (mOrientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
        throw new IllegalStateException("Calling activity must have a static orientation");
    }
    if (DEBUG) Log.d(TAG, "GyroViewListener successfully created.");
}
 
開發者ID:brandenfung,項目名稱:GyroView,代碼行數:23,代碼來源:GyroViewListener.java

示例5: callActivityOnCreate

import android.app.Activity; //導入方法依賴的package包/類
@Override
public void callActivityOnCreate(Activity activity, Bundle icicle) {
    if (icicle != null) {
        BundleCompat.clearParcelledData(icicle);
    }
    VirtualCore.get().getComponentDelegate().beforeActivityCreate(activity);
    IBinder token = mirror.android.app.Activity.mToken.get(activity);
    ActivityClientRecord r = VActivityManager.get().getActivityRecord(token);
    if (r != null) {
        r.activity = activity;
    }
    ContextFixer.fixContext(activity);
    ActivityFixer.fixActivity(activity);
    ActivityInfo info = null;
    if (r != null) {
        info = r.info;
    }
    if (info != null) {
        if (info.theme != 0) {
            activity.setTheme(info.theme);
        }
        if (activity.getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
                && info.screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
            activity.setRequestedOrientation(info.screenOrientation);
        }
    }
    super.callActivityOnCreate(activity, icicle);
    VirtualCore.get().getComponentDelegate().afterActivityCreate(activity);
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:30,代碼來源:AppInstrumentation.java

示例6: lockOrientation

import android.app.Activity; //導入方法依賴的package包/類
public static void lockOrientation(Activity activity) {
    if (activity == null || prevOrientation != -10) {
        return;
    }
    try {
        prevOrientation = activity.getRequestedOrientation();
        WindowManager manager = (WindowManager)activity.getSystemService(Activity.WINDOW_SERVICE);
        if (manager != null && manager.getDefaultDisplay() != null) {
            int rotation = manager.getDefaultDisplay().getRotation();
            int orientation = activity.getResources().getConfiguration().orientation;

            if (rotation == Surface.ROTATION_270) {
                if (orientation == Configuration.ORIENTATION_PORTRAIT) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
                }
            } else if (rotation == Surface.ROTATION_90) {
                if (orientation == Configuration.ORIENTATION_PORTRAIT) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                }
            } else if (rotation == Surface.ROTATION_0) {
                if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                }
            } else {
                if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
                }
            }
        }
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:42,代碼來源:AndroidUtilities.java

示例7: lockOrientation

import android.app.Activity; //導入方法依賴的package包/類
public static void lockOrientation(Activity activity) {
    if (activity == null || prevOrientation != -10) {
        return;
    }
    try {
        prevOrientation = activity.getRequestedOrientation();
        WindowManager manager = (WindowManager) activity.getSystemService(Activity.WINDOW_SERVICE);
        if (manager != null && manager.getDefaultDisplay() != null) {
            int rotation = manager.getDefaultDisplay().getRotation();
            int orientation = activity.getResources().getConfiguration().orientation;

            if (rotation == Surface.ROTATION_270) {
                if (orientation == Configuration.ORIENTATION_PORTRAIT) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
                }
            } else if (rotation == Surface.ROTATION_90) {
                if (orientation == Configuration.ORIENTATION_PORTRAIT) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                }
            } else if (rotation == Surface.ROTATION_0) {
                if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                }
            } else {
                if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:chengzichen,項目名稱:KrGallery,代碼行數:42,代碼來源:AndroidUtilities.java

示例8: lockOrientation

import android.app.Activity; //導入方法依賴的package包/類
public static void lockOrientation(Activity activity) {
    if (activity == null || prevOrientation != -10) {
        return;
    }
    try {
        prevOrientation = activity.getRequestedOrientation();
        WindowManager manager = (WindowManager) activity.getSystemService(Activity.WINDOW_SERVICE);
        if (manager != null && manager.getDefaultDisplay() != null) {
            int rotation = manager.getDefaultDisplay().getRotation();
            int orientation = activity.getResources().getConfiguration().orientation;

            if (rotation == Surface.ROTATION_270) {
                if (orientation == Configuration.ORIENTATION_PORTRAIT) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
                }
            } else if (rotation == Surface.ROTATION_90) {
                if (orientation == Configuration.ORIENTATION_PORTRAIT) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                }
            } else if (rotation == Surface.ROTATION_0) {
                if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                }
            } else {
                if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
                } else {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
                }
            }
        }
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:42,代碼來源:AndroidUtilities.java

示例9: applyRequestedOrientation

import android.app.Activity; //導入方法依賴的package包/類
private static void applyRequestedOrientation(Activity target, ActivityInfo activityInfo) {
    if (target.getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
            && activityInfo.screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
        target.setRequestedOrientation(activityInfo.screenOrientation);
    }
}
 
開發者ID:LiangMaYong,項目名稱:android-apkbox,代碼行數:7,代碼來源:ApkActivityModifier.java


注:本文中的android.app.Activity.getRequestedOrientation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。