Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
覆盖Android WebChromeClient';s onCreateWindow方法会导致SIGSEGV_Android_Webchromeclient - Fatal编程技术网

覆盖Android WebChromeClient';s onCreateWindow方法会导致SIGSEGV

覆盖Android WebChromeClient';s onCreateWindow方法会导致SIGSEGV,android,webchromeclient,Android,Webchromeclient,我试图覆盖默认的WebChromeClient,以使我的应用程序的WebView能够打开新窗口。为此,按照手册中的说明,我将重写WebChromeClient的“onCreateWindow”方法,在该方法中,我执行以下简单逻辑 public boolean onCreateWindow (WebView view, boolean dialog, boolean userGesture, Message resultMsg) { ((WebView.WebViewTr

我试图覆盖默认的WebChromeClient,以使我的应用程序的WebView能够打开新窗口。为此,按照手册中的说明,我将重写WebChromeClient的“onCreateWindow”方法,在该方法中,我执行以下简单逻辑

    public boolean onCreateWindow (WebView view, boolean dialog, boolean userGesture, Message resultMsg) {

        ((WebView.WebViewTransport) resultMsg.obj).setWebView(myWebView);
        Log.d("webviewdemo", "from the chrome client");
        resultMsg.sendToTarget(); 
        return true;
    }
但这导致了上述分割错误。我做了一些搜索,发现它已经在。在那之后,我看不到该问题的任何更新。有人知道同样的情况吗

谢谢,
Ashok.

如果在onCreateWindow中重新使用webview,应用程序将崩溃

在屏幕布局中使用视图组而不是webview,为其提供与webview(mWebViewPopup)相同的布局参数(位置、大小等)

在上述代码中

1) 我已经设置了布局参数,以便我的web视图填充父视图,您应该根据需要使用布局参数。 2) mContext=>context对象 3) contentContainer=>viewgroup,它是用XML声明的,用于包含web视图


这不是干净的,但解决了问题。

答案是,这对我来说没有解决问题,我不确定这是否有意义,如果您删除了任何现有的Web视图,那么您实际上不支持多个窗口,是吗?对我来说,只有在我真正需要的时候,我才有选择地进行
设置。setSupportMultipleWindows(true)
,因此在特定情况下禁用该设置可以解决我的问题。
    @Override
    public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, android.os.Message resultMsg)
    {
        contentContainer.removeAllViews();

        WebView childView = new WebView(mContext);
        childView.getSettings().setJavaScriptEnabled(true);
        childView.setWebChromeClient(this);
        childView.setWebViewClient(new WebViewClient());
        childView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        contentContainer.addView(childView);
        WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
        transport.setWebView(childView);
        resultMsg.sendToTarget();
        return true;
    }