当flash全屏打开时Android WebView为空白-ICS 4.0

当flash全屏打开时Android WebView为空白-ICS 4.0,android,flash,webview,Android,Flash,Webview,我正在构建一个应用程序,它依赖于能够在网络视图中播放Flash,并且在Flash视频全屏播放之前,它已经发现一切都按照预期工作。请求全屏时,屏幕变黑,音频持续约5秒 我最初发现屏幕变白了,但采用了下面文章中的解决方案,从而移动了目标位置。 当全屏flash视频启动时,我在logcat中看到以下内容 08-11 15:09:47.435:V/VideoSurfaceView(23871):表面处理 08-11 15:09:47.435:V/VideoSurfaceView(23871):表面更改

我正在构建一个应用程序,它依赖于能够在网络视图中播放Flash,并且在Flash视频全屏播放之前,它已经发现一切都按照预期工作。请求全屏时,屏幕变黑,音频持续约5秒

我最初发现屏幕变白了,但采用了下面文章中的解决方案,从而移动了目标位置。

当全屏flash视频启动时,我在logcat中看到以下内容

08-11 15:09:47.435:V/VideoSurfaceView(23871):表面处理

08-11 15:09:47.435:V/VideoSurfaceView(23871):表面更改格式=842094169,宽度=480,高度=690

下面的答案参考了在浏览器中实现类似于BaseUI类的onShowCustomView。有一个非常类似的方法叫做showCustomView,我尝试在代码中添加BaseUI类的内容,令人惊讶的是,我成功地使代码编译并运行,但这并没有带来一点盲目的差异


提前感谢您的想法和帮助……

在进一步挖掘之后,我回答了我的问题,这让我进入了下一组问题,我将以单独的问题发布

以下代码将从网络视图全屏显示Flash,只要Flash不请求方向更改。它还中断了源webView,因为在对“指定的子级已具有父级”崩溃进行故障排除后,我被迫添加removeAllViews()方法

另外,将实现WebView作为最终选项以允许从重写的WebChromeClient方法进行访问会中断需要访问此WebView的任何其他方法

public void startWebView(String url){
   final WebView mWebView = (WebView)findViewById(R.id.webview);
   final Context ctx = this;
   WebSettings webSettings = mWebView.getSettings();
        webSettings.setBuiltInZoomControls(true);
        webSettings.setPluginState(WebSettings.PluginState.ON);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setLoadWithOverviewMode(true);

        mWebView.requestFocusFromTouch();
        mWebView.setWebViewClient(new WebViewClient());

        mWebView.setWebChromeClient(new WebChromeClient(){
            protected WebView tempView;
            public void onShowCustomView(View view, int requestedOrientation, WebChromeClient.CustomViewCallback callback){
                super.onShowCustomView(view, callback);   
                if(Build.VERSION.SDK_INT >=14) {
                    if (view instanceof FrameLayout) {                  
                        mWebView.addView(view, new FrameLayout.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT,
                        Gravity.CENTER));                   
                        mWebView.setVisibility(View.VISIBLE);
                    }
                }

                if (mCustomView != null) {
                    callback.onCustomViewHidden();
                    return;
                }

                mOriginalOrientation = activity.getRequestedOrientation();
                FrameLayout decor = (FrameLayout) activity.getWindow().getDecorView();
                mWebView.setVisibility(View.INVISIBLE);
                mFullscreenContainer = new FullscreenHolder(ctx);
                mWebView.removeAllViews();
                mFullscreenContainer.addView(view, COVER_SCREEN_PARAMS);
                decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS);
                mCustomView = view;
                setFullscreen(true);

                mCustomViewCallback = callback;
                activity.setRequestedOrientation(requestedOrientation);

            }


            public void onHideCustomView() {
                if(debug==true)Log.d(name,"onHide start");
                mWebView.setVisibility(View.VISIBLE);


                if(debug==true)Log.d(name,"onHide ");
                if (mCustomView == null)
                    return;
                setFullscreen(false);
                FrameLayout decor = (FrameLayout) activity.getWindow().getDecorView();
                decor.removeView(mFullscreenContainer);
                mFullscreenContainer = null;
                mCustomView = null;
                mCustomViewCallback.onCustomViewHidden();
                if(debug==true)Log.d(name,"onHide callback");
                // Show the content view.
                activity.setRequestedOrientation(mOriginalOrientation);
                if(debug==true)Log.d(name,"onHide set orientation");
                mWebView.loadUrl("http://crooksandliars.com/susie-madrak/scott-brown-cries-over-poor-people-ge");
                if(debug==true)Log.d(name,"onHide start webview");
            }



            public void setFullscreen(boolean enabled) {
                Window win = activity.getWindow();
                WindowManager.LayoutParams winParams = win.getAttributes();
                final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN;
                if (enabled) {
                    winParams.flags |=  bits;
                } else {
                    winParams.flags &= ~bits;
                    if (mCustomView != null) {
                        mCustomView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
                    } else {
                        mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
                    }
                }
                win.setAttributes(winParams);
            }
        });

        mWebView.loadUrl(url);
}



   static class FullscreenHolder extends FrameLayout {

        public FullscreenHolder(Context ctx) {
            super(ctx);
            setBackgroundColor(00000);
        }

        @Override
        public boolean onTouchEvent(MotionEvent evt) {
            return true;
        }
    }
public void startWebView(String url){
   final WebView mWebView = (WebView)findViewById(R.id.webview);
   final Context ctx = this;
   WebSettings webSettings = mWebView.getSettings();
        webSettings.setBuiltInZoomControls(true);
        webSettings.setPluginState(WebSettings.PluginState.ON);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setLoadWithOverviewMode(true);

        mWebView.requestFocusFromTouch();
        mWebView.setWebViewClient(new WebViewClient());

        mWebView.setWebChromeClient(new WebChromeClient(){
            protected WebView tempView;
            public void onShowCustomView(View view, int requestedOrientation, WebChromeClient.CustomViewCallback callback){
                super.onShowCustomView(view, callback);   
                if(Build.VERSION.SDK_INT >=14) {
                    if (view instanceof FrameLayout) {                  
                        mWebView.addView(view, new FrameLayout.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT,
                        Gravity.CENTER));                   
                        mWebView.setVisibility(View.VISIBLE);
                    }
                }

                if (mCustomView != null) {
                    callback.onCustomViewHidden();
                    return;
                }

                mOriginalOrientation = activity.getRequestedOrientation();
                FrameLayout decor = (FrameLayout) activity.getWindow().getDecorView();
                mWebView.setVisibility(View.INVISIBLE);
                mFullscreenContainer = new FullscreenHolder(ctx);
                mWebView.removeAllViews();
                mFullscreenContainer.addView(view, COVER_SCREEN_PARAMS);
                decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS);
                mCustomView = view;
                setFullscreen(true);

                mCustomViewCallback = callback;
                activity.setRequestedOrientation(requestedOrientation);

            }


            public void onHideCustomView() {
                if(debug==true)Log.d(name,"onHide start");
                mWebView.setVisibility(View.VISIBLE);


                if(debug==true)Log.d(name,"onHide ");
                if (mCustomView == null)
                    return;
                setFullscreen(false);
                FrameLayout decor = (FrameLayout) activity.getWindow().getDecorView();
                decor.removeView(mFullscreenContainer);
                mFullscreenContainer = null;
                mCustomView = null;
                mCustomViewCallback.onCustomViewHidden();
                if(debug==true)Log.d(name,"onHide callback");
                // Show the content view.
                activity.setRequestedOrientation(mOriginalOrientation);
                if(debug==true)Log.d(name,"onHide set orientation");
                mWebView.loadUrl("http://crooksandliars.com/susie-madrak/scott-brown-cries-over-poor-people-ge");
                if(debug==true)Log.d(name,"onHide start webview");
            }



            public void setFullscreen(boolean enabled) {
                Window win = activity.getWindow();
                WindowManager.LayoutParams winParams = win.getAttributes();
                final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN;
                if (enabled) {
                    winParams.flags |=  bits;
                } else {
                    winParams.flags &= ~bits;
                    if (mCustomView != null) {
                        mCustomView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
                    } else {
                        mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
                    }
                }
                win.setAttributes(winParams);
            }
        });

        mWebView.loadUrl(url);
}



   static class FullscreenHolder extends FrameLayout {

        public FullscreenHolder(Context ctx) {
            super(ctx);
            setBackgroundColor(00000);
        }

        @Override
        public boolean onTouchEvent(MotionEvent evt) {
            return true;
        }
    }