在 Android webview 中禁用页面转发 [英] Disable page forwarding in Android webview

查看:60
本文介绍了在 Android webview 中禁用页面转发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示广告(不是我的广告)的网络视图,问题是当用户点击x"按钮退出广告时,广告仍将他们定向到某个网站.我想知道的是,由于我无法控制广告,我可以在 webview 中禁用页面定向/转发吗?这意味着即使用户点击我的 webview 中的链接也不会发生任何事情.

I have a webview that shows ads (not my ads), the problem is when user clicks the "x" button to exit the ad, the ad still directs them to a site. What I wonder is since I can't control the ads, can I instead Disable page directing/forwarding inside webview? that means even if user clicks a link inside my webview nothing should happen.

推荐答案

您正在寻找 WebClient.shouldOverrideUrlLoading 方法.

You are looking for WebClient.shouldOverrideUrlLoading method.

 webview.setWebViewClient(new WebViewClient() {
   public boolean shouldOverrideUrlLoading (WebView view, String url){
       //True if the host application wants to leave the current WebView and handle the url itself, otherwise return false.
       return true;
   }
 });

这篇关于在 Android webview 中禁用页面转发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆