android - 我可以使用 shouldInterceptRequest 来阻止 Android 中的特定调用吗?

标签 android android-intent

我使用了下面的代码

public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    alertsavedinternal(); //display an alert
    Log.d("DEBUG", "Should intercept request" +url); 
    //log the url to console in debug mode.
    return null;
}

但是,当显示警报时,我的控制台还会打印日志,此外,还会在后台加载 url。我怎样才能阻止 url 加载?

请纠正我对这个函数的理解。

谢谢

最佳答案

如果在 shouldInterceptRequest 中返回 null,则表示 WebView 将照常继续加载资源。

这就是您看到 URL 仍在加载的原因。

为了拦截和阻止调用,您需要返回自己的(非空)数据。

关于android - 我可以使用 shouldInterceptRequest 来阻止 Android 中的特定调用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16044554/

相关文章:

android - 谷歌附近的通知

android - 数字选择器数据未正确显示 android

java - 第二个 Activity 不会返回到第一个 Activity

java - 如何保持列表项和数据库行之间的连接?

android - 已激活时终止 Activity

java - Android 在一切之上叠加一个 View ?

java - android studio 构建失败,因为 "Cannot cast object ' 1 1' with class ' java.lang.Integer' to class "

android 兼容性包 - fragment ...未附加到 Activity

android - 您可以在运行时注册 url Intent 吗?

android - Intent 和 Parcelable 对象 Android