gpt4 book ai didi

java - Android onConfigurationChanged 不起作用

转载 作者:行者123 更新时间:2023-12-02 06:49:24 31 4
gpt4 key购买 nike

我第一次尝试这个,所以不知道它,但需要尽快修复。当我将设备旋转到横向时,我试图让它产生新的 Intent 。

这是我的代码:

 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>

非常感谢查尔顿桑塔纳

最佳答案

android:configChanges="keyboardHidden|orientation|screenSize"

在meanifeast的 Activity 标签中

关于java - Android onConfigurationChanged 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18232834/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com