android – 为什么我的全屏webview在打开后会立即关闭?

前端之家收集整理的这篇文章主要介绍了android – 为什么我的全屏webview在打开后会立即关闭?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的全屏视频网页视图几乎总是在打开后立即关闭,有时它可以正常工作.几乎每次我点击youtube视频上的全屏按钮时,您都可以看到屏幕闪烁到全屏并恢复原状.这可能是什么原因?

webview显示在tablayout / viewpager设置中,其中包含一些其他片段.

我用这段代码显示视频:
https://github.com/cprcrack/VideoEnabledWebView

现在我正在使用这个https://github.com/GoogleChrome/chromium-webview-samples/blob/master/fullscreen-video-sample/app/src/main/java/fullscreenvideosample/android/chrome/google/com/fullscreenvideosample/MainActivity.java

它们产生完全相同的行为.

全屏失败时记录并在打开后立即恢复正常:

07-14 17:41:06.694 D/ViewRootImpl@33432e1[GroupActivity]: ViewPostImeInputStage processPointer 0
07-14 17:41:06.786 D/ViewRootImpl@33432e1[GroupActivity]: ViewPostImeInputStage processPointer 1
07-14 17:41:06.803 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392
07-14 17:41:07.512 D/ViewRootImpl@33432e1[GroupActivity]: ViewPostImeInputStage processPointer 0
07-14 17:41:07.592 D/ViewRootImpl@33432e1[GroupActivity]: ViewPostImeInputStage processPointer 1
07-14 17:41:07.615 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392
07-14 17:41:07.709 V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@3e22579 nm : com.linkhubapp ic=null
07-14 17:41:07.709 I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
07-14 17:41:07.713 D/InputTransport: Input channel constructed: fd=152
07-14 17:41:07.714 D/InputTransport: Input channel destroyed: fd=159
07-14 17:41:07.714 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392
07-14 17:41:07.751 D/ViewRootImpl@33432e1[GroupActivity]: Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,2560] result=0x1 surface={isValid=true -1176543232} surfaceGenerationChanged=false
07-14 17:41:07.911 D/ViewRootImpl@33432e1[GroupActivity]: Relayout returned: oldFrame=[0,2560] result=0x7 surface={isValid=true -1273339904} surfaceGenerationChanged=true
07-14 17:41:07.921 D/mali_winsys: EGLint new_window_surface(egl_winsys_display*,void*,EGLSurface,EGLConfig,egl_winsys_surface**,egl_color_buffer_format*,EGLBoolean) returns 0x3000,[1440x2560]-format:1
07-14 17:41:07.922 D/ViewRootImpl@33432e1[GroupActivity]: mHardwareRenderer.updateSurface() mSurface={isValid=true -1273339904}
07-14 17:41:07.974 D/SurfaceView: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,875][1440,1685] result=0x7 surface={Surface(name=null)/@0xb9ffb70 isValid=true -1178691584}
07-14 17:41:08.047 D/SurfaceView: Relayout returned: oldFrame=[0,1685] newFrame=[0,1685] result=0x5 surface={Surface(name=null)/@0xb9ffb70 isValid=false 0}
07-14 17:41:08.095 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392
07-14 17:41:08.163 D/ViewRootImpl@33432e1[GroupActivity]: Relayout returned: oldFrame=[0,2560] result=0x1 surface={isValid=true -1273339904} surfaceGenerationChanged=false
07-14 17:41:08.232 V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@1772e0f nm : com.linkhubapp ic=null
07-14 17:41:08.232 I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
07-14 17:41:08.233 D/InputTransport: Input channel constructed: fd=173
07-14 17:41:08.233 D/InputTransport: Input channel destroyed: fd=152

全屏成功时记录日志:

07-14 17:41:27.987 D/ViewRootImpl@33432e1[GroupActivity]: ViewPostImeInputStage processPointer 0
07-14 17:41:28.023 D/ViewRootImpl@33432e1[GroupActivity]: ViewPostImeInputStage processPointer 1
07-14 17:41:28.048 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392
07-14 17:41:28.496 D/ViewRootImpl@33432e1[GroupActivity]: ViewPostImeInputStage processPointer 0
07-14 17:41:28.571 D/ViewRootImpl@33432e1[GroupActivity]: ViewPostImeInputStage processPointer 1
07-14 17:41:28.616 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392
07-14 17:41:28.719 V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@80b2646 nm : com.linkhubapp ic=null
07-14 17:41:28.719 I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
07-14 17:41:28.725 D/InputTransport: Input channel constructed: fd=155
07-14 17:41:28.725 D/InputTransport: Input channel destroyed: fd=173
07-14 17:41:28.725 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392
07-14 17:41:28.766 D/ViewRootImpl@33432e1[GroupActivity]: Relayout returned: oldFrame=[0,2560] result=0x1 surface={isValid=true -1273339904} surfaceGenerationChanged=false
07-14 17:41:28.956 D/ViewRootImpl@33432e1[GroupActivity]: Relayout returned: oldFrame=[0,2560] result=0x1 surface={isValid=true -1273339904} surfaceGenerationChanged=false
07-14 17:41:29.036 D/SurfaceView: Relayout returned: oldFrame=[0,1685] result=0x7 surface={Surface(name=null)/@0xc360d2 isValid=true -1273337856}
07-14 17:41:29.089 D/SurfaceView: Relayout returned: oldFrame=[0,1685] result=0x1 surface={Surface(name=null)/@0xc360d2 isValid=true -1311279104}

编辑:
它似乎只在youtube上发生.测试过Vimeo和youtube. Vimeo每次都会打开.

解决方法

我能想到的最好的事情是你的设备没有内存.所以我有一些建议给你.

>首先,当你的所有ram都是空闲的时候在你的设备上测试它并检查结果.
>其次,你已经提到你有一个Galaxy S6和一个Galaxy S3,在两个设备上运行你的应用程序.
>如果您可以在另一台Galaxy S6上测试您的应用并查看它是否重复,那么它非常有用.

收集这些信息后,您可以找到解决问题的方法.

您可以测试的另一件事是使用android:hardwareAccelerated =“true”并检查它是否有帮助.

猜你在找的Android相关文章