Aou*_*bri 1 redirect android webview
我有一个显示广告(不是我的广告)的网络视图,问题是当用户点击“x”按钮退出广告时,广告仍然将他们定向到一个网站。我想知道的是,由于我无法控制广告,我可以在 webview 中禁用页面定向/转发吗?这意味着即使用户单击我的 webview 中的链接,也不应该发生任何事情。
您正在寻找WebClient.shouldOverrideUrlLoading方法。
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;
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10458 次 |
| 最近记录: |