当前位置: 首页>>代码示例>>Java>>正文


Java Activity.setRequestedOrientation方法代码示例

本文整理汇总了Java中android.app.Activity.setRequestedOrientation方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.setRequestedOrientation方法的具体用法?Java Activity.setRequestedOrientation怎么用?Java Activity.setRequestedOrientation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.setRequestedOrientation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: callActivityOnCreate

import android.app.Activity; //导入方法依赖的package包/类
@Override
public void callActivityOnCreate(Activity activity, Bundle icicle) {
    final Intent intent = activity.getIntent();
    if (PluginUtil.isIntentFromPlugin(intent)) {
        Context base = activity.getBaseContext();
        try {
            LoadedPlugin plugin = this.mPluginManager.getLoadedPlugin(intent);
            ReflectUtil.setField(base.getClass(), base, "mResources", plugin.getResources());
            ReflectUtil.setField(ContextWrapper.class, activity, "mBase", plugin.getPluginContext());
            ReflectUtil.setField(Activity.class, activity, "mApplication", plugin.getApplication());
            ReflectUtil.setFieldNoException(ContextThemeWrapper.class, activity, "mBase", plugin.getPluginContext());

            // set screenOrientation
            ActivityInfo activityInfo = plugin.getActivityInfo(PluginUtil.getComponent(intent));
            if (activityInfo.screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
                activity.setRequestedOrientation(activityInfo.screenOrientation);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    mBase.callActivityOnCreate(activity, icicle);
}
 
开发者ID:didi,项目名称:VirtualAPK,代码行数:26,代码来源:VAInstrumentation.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: rotationState

import android.app.Activity; //导入方法依赖的package包/类
@Test
public void rotationState() throws Exception {

    //arrange
    Activity activity = new StateBuilder(mockCounterWithLambdas, mockCounterWithProgress)
            .counterWithProgressIsBusy(true)
            .counterWithProgressProgressValue(7)
            .counterWithProgressCount(40)
            .counterBasicIsBusy(false)
            .counterBasicCount(0)
            .createRule()
            .launchActivity(null);
    activity.setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE);

    //act
    activity.setRequestedOrientation(SCREEN_ORIENTATION_PORTRAIT);

    //assert
    onView(withId(R.id.counterwprog_increase_btn)).check(matches(not(isEnabled())));
    onView(withId(R.id.counterwprog_busy_progress)).check(matches(isDisplayed()));
    onView(withId(R.id.counterwprog_progress_txt)).check(matches(withText("7")));
    onView(withId(R.id.counterwprog_current_txt)).check(matches(withText("40")));
    onView(withId(R.id.counterwlambda_increase_btn)).check(matches(isEnabled()));
    onView(withId(R.id.counterwlambda_busy_progress)).check(matches(not(isDisplayed())));
    onView(withId(R.id.counterwlambda_current_txt)).check(matches(withText("0")));
}
 
开发者ID:erdo,项目名称:asaf-project,代码行数:27,代码来源:CounterViewTest.java

示例4: stateMaintainedAfterRotation

import android.app.Activity; //导入方法依赖的package包/类
@Test
public void stateMaintainedAfterRotation() throws Exception {

    //arrange
    Activity activity = new StateBuilder(mockPlaylistAdvancedModel, mockPlaylistSimpleModel)
            .withAdvancedPlaylistHavingTracks(3)
            .withSimplePlaylistHavingTracks(3)
            .withPlaylistsContainingTracks(new Track(R.color.pastel1))
            .createRule()
            .launchActivity(null);
    activity.setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE);

    onView(withId(R.id.playlist_addMany1_button)).check(matches(isEnabled()));
    onView(withId(R.id.playlist_removeMany1_button)).check(matches(not(isEnabled())));
    onView(withId(R.id.playlist_totaltracks1_textview)).check(matches(withText("[3]")));

    //act
    activity.setRequestedOrientation(SCREEN_ORIENTATION_PORTRAIT);

    //assert
    onView(withId(R.id.playlist_addMany1_button)).check(matches(isEnabled()));
    onView(withId(R.id.playlist_removeMany1_button)).check(matches(not(isEnabled())));
    onView(withId(R.id.playlist_totaltracks1_textview)).check(matches(withText("[3]")));
}
 
开发者ID:erdo,项目名称:asaf-project,代码行数:25,代码来源:PlaylistsViewTest.java

示例5: perform

import android.app.Activity; //导入方法依赖的package包/类
@Override
public void perform(UiController uiController, View view) {
    uiController.loopMainThreadUntilIdle();
    final Activity activity = (Activity) view.getContext();
    activity.setRequestedOrientation(orientation);

    Collection<Activity> resumedActivities = ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(Stage.RESUMED);
    if (resumedActivities.isEmpty()) {
        throw new RuntimeException("Could not change orientation");
    }
}
 
开发者ID:kevalpatel2106,项目名称:smart-lens,代码行数:12,代码来源:OrientationChangeAction.java

示例6: sysIsLockScreen

import android.app.Activity; //导入方法依赖的package包/类
public static void sysIsLockScreen(Activity act, boolean isLock) {
    if (isLock) {
        switch (act.getResources().getConfiguration().orientation) {
            case 1:
                act.setRequestedOrientation(1);
                return;
            case 2:
                act.setRequestedOrientation(0);
                return;
            default:
                return;
        }
    }
    act.setRequestedOrientation(-1);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:Util.java

示例7: unlockAllOrientations

import android.app.Activity; //导入方法依赖的package包/类
@ReactMethod
public void unlockAllOrientations() {
    final Activity activity = getCurrentActivity();
    if (activity == null) return;
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    this.isLocked = false;
}
 
开发者ID:wonday,项目名称:react-native-orientation-locker,代码行数:8,代码来源:OrientationModule.java

示例8: lockToLandscapeRight

import android.app.Activity; //导入方法依赖的package包/类
@ReactMethod
public void lockToLandscapeRight() {
    final Activity activity = getCurrentActivity();
    if (activity == null) {
        return;
    }
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
}
 
开发者ID:Intellicode,项目名称:react-native-screen-orientation,代码行数:9,代码来源:OrientationModule.java

示例9: rotateToLandscape

import android.app.Activity; //导入方法依赖的package包/类
private static void rotateToLandscape(Activity activity) {
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
 
开发者ID:graviton57,项目名称:DOUSalaries,代码行数:4,代码来源:TestUtils.java

示例10: rotateToPortrait

import android.app.Activity; //导入方法依赖的package包/类
private static void rotateToPortrait(Activity activity) {
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:TestUtils.java

示例11: GiraffePlayer

import android.app.Activity; //导入方法依赖的package包/类
public GiraffePlayer(final Activity activity) {
    log = LogUtil.getInstance();
    /*通过sharepreference得到屏幕参数*/
    SharedPreferences sharedPreferences= activity.getSharedPreferences("screeninfo",
            Activity.MODE_PRIVATE);
    mWidthPixels =sharedPreferences.getInt("widthPixels", 0);
    mHeightPixels =sharedPreferences.getInt("heightPixels",0);
    try {
        IjkMediaPlayer.loadLibrariesOnce(null);
        IjkMediaPlayer.native_profileBegin("libijkplayer.so");
        playerSupport=true;
    } catch (Throwable e) {
        log.e("GiraffePlayer", "loadLibraries error"+e);
    }
    this.activity=activity;
    $=new Query(activity);

    /*初始化控件*/
    initViews();

     /*声音*/
    voiceThread = new VoiceThread();
    voiceThread.start();

    /*初始化屏幕监听*/
    orientationEventListener = new OrientationEventListener(activity) {
        @Override
        public void onOrientationChanged(int orientation) {
            if (orientation >= 0 && orientation <= 30 || orientation >= 330 || (orientation >= 150 && orientation <= 210)) {
                //竖屏
                if (portrait) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
                    orientationEventListener.disable();
                }
            } else if ((orientation >= 90 && orientation <= 120) || (orientation >= 240 && orientation <= 300)) {
                if (!portrait) {
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
                    orientationEventListener.disable();
                }
            }
        }
    };
    portrait=true;
    initHeight=activity.findViewById(R.id.app_video_box).getLayoutParams().height;
    if (!playerSupport) {
        showStatus(activity.getResources().getString(R.string.not_support));
    }

    /*初始化隐藏显示控件列表*/
    initViewList();
}
 
开发者ID:lisnstatic,项目名称:live_master,代码行数:52,代码来源:GiraffePlayer.java

示例12: unlockOrientation

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Unlocks the device window in user defined screen mode.
 */
public static void unlockOrientation(Activity activity) {
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
}
 
开发者ID:davideas,项目名称:AndroidBlueprints,代码行数:7,代码来源:Utils.java

示例13: setPortrait

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 设置屏幕为竖屏
 *
 * @param activity activity
 */
public static void setPortrait(Activity activity) {
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:9,代码来源:ScreenUtils.java

示例14: setPortrait

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 设置屏幕为竖屏
 *
 * @param activity activity
 */
public static void setPortrait(@NonNull final Activity activity) {
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:ScreenUtils.java

示例15: setLandscape

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 设置屏幕为横屏
 * <p>还有一种就是在Activity中加属性android:screenOrientation="landscape"</p>
 * <p>不设置Activity的android:configChanges时,切屏会重新调用各个生命周期,切横屏时会执行一次,切竖屏时会执行两次</p>
 * <p>设置Activity的android:configChanges="orientation"时,切屏还是会重新调用各个生命周期,切横、竖屏时只会执行一次</p>
 * <p>设置Activity的android:configChanges="orientation|keyboardHidden|screenSize"(4.0以上必须带最后一个参数)时
 * 切屏不会重新调用各个生命周期,只会执行onConfigurationChanged方法</p>
 *
 * @param activity activity
 */
public static void setLandscape(Activity activity) {
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:14,代码来源:ScreenUtils.java


注:本文中的android.app.Activity.setRequestedOrientation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。