本文整理汇总了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);
}
示例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);
}
示例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")));
}
示例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]")));
}
示例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");
}
}
示例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);
}
示例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;
}
示例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);
}
示例9: rotateToLandscape
import android.app.Activity; //导入方法依赖的package包/类
private static void rotateToLandscape(Activity activity) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
示例10: rotateToPortrait
import android.app.Activity; //导入方法依赖的package包/类
private static void rotateToPortrait(Activity activity) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
示例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();
}
示例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);
}
示例13: setPortrait
import android.app.Activity; //导入方法依赖的package包/类
/**
* 设置屏幕为竖屏
*
* @param activity activity
*/
public static void setPortrait(Activity activity) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
示例14: setPortrait
import android.app.Activity; //导入方法依赖的package包/类
/**
* 设置屏幕为竖屏
*
* @param activity activity
*/
public static void setPortrait(@NonNull final Activity activity) {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
示例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);
}