本文介绍了从onCreateWindow Web视图处理网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以从呼吁onCreateWindow web视图上得到的网址?

  @覆盖
        公共布尔onCreateWindow(的WebView视图,布尔isDialog,布尔isUserGesture,留言resultMsg)
        {        }


解决方案

试试这个。

  @覆盖
        公共布尔onCreateWindow(的WebView视图,布尔isDialog,
                布尔isUserGesture,信息resultMsg){
            Logger.d(Constants.TAGonCreateWindow+ resultMsg);
            的WebView targetWebView =新的WebView(getActivity()); //传递上下文
            targetWebView.setWebViewClient(新WebViewClient(){
                @覆盖
                公共无效onPageStarted(的WebView视图,字符串URL,
                        位图图标){
                    handleWebViewLinks(URL); //你可以在这里得到你的目标网址
                    super.onPageStarted(查看,网址,图标);
                }
            });
            WebView.WebViewTransport运输=(WebView.WebViewTransport)resultMsg.obj;
            transport.setWebView(targetWebView);
            resultMsg.sendToTarget();
            返回true;
        }

Can I get url from calling onCreateWindow on webView?

        @Override
        public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg)
        {

        }
解决方案

Try this.

 @Override
        public boolean onCreateWindow(WebView view, boolean isDialog,
                boolean isUserGesture, Message resultMsg) {
            Logger.d(Constants.TAG, "onCreateWindow"+resultMsg);
            WebView targetWebView = new WebView(getActivity()); // pass a context
            targetWebView.setWebViewClient(new WebViewClient(){
                @Override
                public void onPageStarted(WebView view, String url,
                        Bitmap favicon) {
                    handleWebViewLinks(url); // you can get your target url here
                    super.onPageStarted(view, url, favicon);
                }
            });
            WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
            transport.setWebView(targetWebView);
            resultMsg.sendToTarget();
            return true;
        }

这篇关于从onCreateWindow Web视图处理网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 19:55