0

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

这是我的代码:

 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>

非常感谢查尔顿桑塔纳

4