VideoView 横向显示为启动画面

VideoView on landscape as splash screen

我想在启动时创建启动画面。我还创建了一个 activity_splash.xml。 这是我的 Java 代码:

public class SplashScreen extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
            VideoView videoHolder = new VideoView(this);
            setContentView(videoHolder);
            Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.splash);
            videoHolder.setVideoURI(video);
            videoHolder.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                public void onCompletion(MediaPlayer mp) {
                    jump();
                }
            });
            videoHolder.start();
        } catch (Exception ex) {
            jump();
        }
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        jump();
        return true;
    }

    private void jump() {
        if (isFinishing())
            return;
        startActivity(new Intent(this, MainActivity.class));
        finish();
    }
}

这是我的AndroidManifest.xml

<activity android:name=".SplashScreen"
        android:configChanges="orientation"
        android:screenOrientation="landscape">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

我想link VideoView 这个activity_splash.xml

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="me.smash_it.smashit.SplashScreen">

    <VideoView
        android:id="@+id/videoView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:layout_gravity="center"
        android:layout_centerInParent="true"/>
</RelativeLayout>

我已经在我的 Java 代码中尝试过:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        try {
             setContentView(R.layout.activity_splash);
            VideoView videoHolder = (VideoView) this.findViewById(R.id.videoView);
            VideoView videoHolder = new VideoView(this);
            .....
    }

当我尝试它时,它没有显示我的启动画面,它直接启动了我的另一个 activity,那就是 Webview。如果查看我的调试,我会收到此错误:

11-07 08:16:49.591 7974-8029/[PROJECT_NAME] E/libEGL: validate_display:99 error 3008 (EGL_BAD_DISPLAY)

有谁知道我做错了什么或者那个错误是什么意思?我已经在真实设备上进行了测试,但仍然出现该错误。

提前致谢!

我试过这个:

super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    try {
            VideoView videoHolder = (VideoView)findViewById(R.id.videoView);
            setContentView(videoHolder);
            Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.splash);
            videoHolder.setVideoURI(video);
            videoHolder.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                public void onCompletion(MediaPlayer mp) {
                    jump();
                }
            });
            videoHolder.start();
        } catch (Exception ex) {
            jump();
        }

就像你看到的那样,我使用了两次 setContentView 我将创建的视图放在 setContentView 中是什么给我带来了错误。我唯一需要做的就是删除这个 setContentView(videoHolder);.