videoview无法添加窗口 - 令牌null不适用于应用程序

时间:2017-03-08 01:58:42

标签: android android-videoview

当我使用VideoView时,它会引发异常。这是我的代码:

mMediaController = new MediaController(this);
mVideoView.setVideoURI(Uri.parse("http://www.somesite.com/household/uploads/jobs.mp4"));
mVideoView.setMediaController(mMediaController);
mVideoView.requestFocus();

这是一个例外:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.spark.peak, PID: 12065
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
    at android.view.ViewRootImpl.setView(ViewRootImpl.java:853)
    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:337)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
    at android.app.Dialog.show(Dialog.java:350)
    at android.app.AlertDialog$Builder.show(AlertDialog.java:1113)
    at android.widget.VideoView$5.onError(VideoView.java:560)
    at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:3823)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7233)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

你能帮助我吗?

0 个答案:

没有答案