当前位置: 首页>>代码示例>>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;未经允许,请勿转载。