open ads in external browser in webview android

前端 未结 2 1378
太阳男子
太阳男子 2020-12-20 02:10

I created app with webview, and i want load all internal links in webview and load external links in android browser. Now problem is I am using html ads and when i click on

2条回答
  •  时光说笑
    2020-12-20 02:51

    I did the some modifications and it is working perfectly for banner ads. I have made following changes:

    • changed if condition.
    • I am returning false for 'if' block as documentation says:

    If WebViewClient is provided, return true means the host application handles the url, while return false means the current WebView handles the url

    @Override   
    public boolean shouldOverrideUrlLoading(WebView view, String url) 
    { 
        if (url.contains("www.mysite.com")) 
        {
           view.loadUrl(url);
           return false;
        }else
        {
           Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
           startActivity(intent);
           return true;
        }
    }
    

提交回复
热议问题