Videoview Unable to add window - null token is not for application

when I use videooview it throws an exception, the code looks like this:

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

and exception:

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)

Could you help me?

+4
source share

Source: https://habr.com/ru/post/1671762/


All Articles