當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。