旋转手机时如何切换到其他活动?
我的要求:
我可以创建此行为,需要后退按钮。按下该按钮,我会得到横向A / B或纵向L的效果,这是我想避免的。
我在做什么(活动A和B,但L相似)
要在定向改变时触发活动调用:
@Override
public void onConfigurationChanged(Configuration newConfig) {
int newOrientation = newConfig.orientation;
if (newOrientation == Configuration.ORIENTATION_LANDSCAPE) {
Intent intent = new Intent(this, ActivityL.class);
startActivity(intent);
}
super.onConfigurationChanged(newConfig);
}
我想要以下内容。但是手动(重新)设置方向完全无法调用onConfigurationChanged():
@Override
public void onResume(){
super.onResume();
int currentOrientation = this.getResources().getConfiguration().orientation;
if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}
当然,如果我在其他生命周期方法或onCreate(...)中这样做,也会发生同样的情况。>>
所有活动都有:
android:screenOrientation="sensor"
我也尝试使用旋转角度来模拟方向变化,但是行为似乎主要是随机的,甚至不接近正常的方向变化。
旋转手机时如何切换到其他活动?我的要求:活动A和B仅是肖像Acitvity L仅是风景当显示A或B的风景模式时,L为...
我想setRequestedOrientation()会覆盖我在AndroidManifest中定义的内容: