我試圖讓WebView內的YouTube視頻以全屏顯示。問題是,在視頻顯示後第二秒左右,該應用程序崩潰並伴有BadTokenException。BadTokenException嘗試顯示全屏HTML5視頻
我正在使用的代碼線路幾乎線從這裏: Android WebView with an embedded youtube video, full screen button freezes video
我唯一改變的是要讓它符合我的行爲和我的觀點。它運行良好(不顯示視頻),如果我註釋掉設置內容視圖的行。
我也試着將代碼從這裏: http://shashikawlp.wordpress.com/2013/06/25/play-html5-video-on-android-webview/
,但我得到了同樣的問題。
下面是從調試器堆棧:
ViewRootImpl.setView(View, WindowManager$LayoutParams, View) line: 661
WindowManagerImpl.addView(View, ViewGroup$LayoutParams, CompatibilityInfoHolder, boolean) line: 326
WindowManagerImpl.addView(View, ViewGroup$LayoutParams, CompatibilityInfoHolder) line: 224
WindowManagerImpl$CompatModeWrapper.addView(View, ViewGroup$LayoutParams) line: 149
HTML5VideoFullScreen$FullScreenMediaController(MediaController).show(int) line: 338
HTML5VideoFullScreen$FullScreenMediaController(MediaController).show() line: 298
HTML5VideoFullScreen$FullScreenMediaController.show() line: 374
HTML5VideoFullScreen.onPrepared(MediaPlayer) line: 220
MediaPlayer$EventHandler.handleMessage(Message) line: 2071
MediaPlayer$EventHandler(Handler).dispatchMessage(Message) line: 99
爲什麼FullScreenMediaController沒有得到正確的窗口上下文上創建本身,這似乎是問題的根源任何想法?