嗨,我为启动屏幕设置了一个视频,它在android 4.4.4以上显示,但在android 4.4.2上却没有显示
**这是我的代码**
videoView = findViewById(R.id.videoView1);
Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.splash);
videoView.setVideoURI(video);
videoView.setZOrderOnTop(true);
videoView.setMediaController(new MediaController(this));
videoView.requestFocus();
videoView.start();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(SplshScreen.this, MainActivity.class));
finish();
}
}, 1500);
logcat错误:
Activity.SplshScreen has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{9d069060 V.E..... R.....ID 0,0-1026,318} that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:348)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.app.Dialog.show(Dialog.java:286)
at android.app.AlertDialog$Builder.show(AlertDialog.java:951)
at android.widget.VideoView$5.onError(VideoView.java:515)
at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:2248)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
先谢谢!
答案 0 :(得分:1)
在videoView.setVideoURI(video);
之后添加此代码段
videoView.setOnPreparedListener(this);
希望它能起作用。