我开发了一个应用程序,我在 webview 中加载我的 youtube 频道,它按预期工作正常。我能够在小屏幕和全屏模式下播放视频。
但问题是,如果我在全屏模式下播放视频时将应用程序置于后台,并将其置于前台应用程序崩溃。我已经看到了崩溃日志,但它没有显示我的代码中的任何内容我没有得到崩溃背后的原因。它显示了 NullPointerException 但它的来源是一个谜。
Logcat :
08-09 14:21:33.480: E/AndroidRuntime(10157): FATAL EXCEPTION: main
08-09 14:21:33.480: E/AndroidRuntime(10157): java.lang.NullPointerException
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.webkit.HTML5VideoFullScreen.prepareForFullScreen(HTML5VideoFullScreen.java:187)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.webkit.HTML5VideoFullScreen.access$600(HTML5VideoFullScreen.java:24)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.webkit.HTML5VideoFullScreen$2.surfaceCreated(HTML5VideoFullScreen.java:124)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.SurfaceView.updateWindow(SurfaceView.java:609)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:235)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.View.dispatchWindowVisibilityChanged(View.java:7678)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1047)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1335)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1112)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4472)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.Choreographer.doCallbacks(Choreographer.java:555)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.Choreographer.doFrame(Choreographer.java:525)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.os.Handler.handleCallback(Handler.java:615)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.os.Looper.loop(Looper.java:137)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
android.app.ActivityThread.main(ActivityThread.java:4898)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
java.lang.reflect.Method.invokeNative(Native Method)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
java.lang.reflect.Method.invoke(Method.java:511)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
08-09 14:21:33.480: E/AndroidRuntime(10157): at
dalvik.system.NativeStart.main(Native Method)
如果我将应用程序置于后台,而视频仅在小屏幕上播放,则应用程序不会崩溃。