Android - Open target _blank links in WebView with external browser

前端 未结 5 1398
忘掉有多难
忘掉有多难 2020-12-01 06:37

I build a WebView which displays a website. The website contains links without a target=\"_blank\" attribute and some with it.

I need to op

5条回答
  •  清歌不尽
    2020-12-01 07:02

    private  WebView WEB_v;
    

    if you open new window when you click a link any 2nd window, then it I will open by another browser

     WEB_v.getSettings().setSupportMultipleWindows(true);
        WEB_v.setWebChromeClient(new WebChromeClient() {
            @Override
            public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, android.os.Message resultMsg)
            {
                WebView.HitTestResult result = view.getHitTestResult();
                String data = result.getExtra();
                Context context = view.getContext();
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(data));
                context.startActivity(browserIntent);
                return false;
            }
        });
    

提交回复
热议问题