Java Android OnConfiguration已更改无法工作
我第一次尝试这个,所以不知道它,但需要尽快修复。当我将设备旋转到横向时,我试图让它实现一个新的意图 这是我的密码:Java Android OnConfiguration已更改无法工作,java,android,android-intent,orientation,Java,Android,Android Intent,Orientation,我第一次尝试这个,所以不知道它,但需要尽快修复。当我将设备旋转到横向时,我试图让它实现一个新的意图 这是我的密码: public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Checks the orientation of the screen if (newConfig.orientation == Config
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
Intent i = new Intent(getApplicationContext(),
VideoLandscape.class);
i.putExtra("url", LINK);
i.putExtra("small", videoPath);
startActivity(i);
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
}
}
//Manifest
<activity
android:name="com.****.media.tv.Video"
android:configChanges="orientation|keyboardHidden"
android:label="@string/title_TV">
</activity>
<activity
android:name="com.****.media.tv.VideoLandscape"
android:label="@string/title_TV">
</activity>
public void onconfiguration已更改(配置newConfig){
super.onConfigurationChanged(newConfig);
//检查屏幕的方向
if(newConfig.orientation==Configuration.orientation\u横向){
Toast.makeText(此为“横向”,Toast.LENGTH_SHORT).show();
意图i=新意图(getApplicationContext(),
视像景观(类);
i、 putExtra(“url”,链接);
i、 putExtra(“小”,视频路径);
星触觉(i);
}else if(newConfig.orientation==Configuration.orientation\u纵向){
Toast.makeText(这是“肖像”,Toast.LENGTH_SHORT).show();
}
}
//显示
非常感谢
查尔顿桑塔纳酒店
android:configChanges="keyboardHidden|orientation|screenSize"
在MeaniFast的活动标签中您需要在
android:configChanges
属性中添加| screenSize
属性,如下所示
android:configChanges="keyboardHidden|orientation|screenSize"
因为在API级别13之后有一点变化,这在处理文件中提到onConfigurationChanged()
将相同的
android:configChanges=“orientation | keyboardHidden”
放在com.***.media.tv.videoscape
的中,如果(newConfig.orientation==Configuration.orientation\u trait){
为第一个活动放置新的意图开始:intent i=newintent(getApplicationContext(),videograit.class);i.putExtra(“url”,LINK);i.putExtra(“small”,videoPath);startActivity(i);
。