【问题标题】:Android Webview shouldoverrideurlloading only called when url redirectedAndroid Webview shouldoverrideurlloading 仅在 url 重定向时调用
【发布时间】:2017-07-04 05:35:13
【问题描述】:

我在 Activity 中有一个 WebView,它有一个带有 shouldoverrideurlloading 的 webviewclient。

当我加载 https://mobile.twitter.com/ 时,不应该调用 shouldoverrideurlloading 因为它没有重定向, 但它在加载 http://mobile.twitter.com. (http 协议重定向到 http)

时有效

我已经测试了近 20 个 url,shouldoverrideurlloading 仅在 url 重定向时调用。

在任何情况下使用 shouldoverrideurlloading 是否需要任何条件或设置? (POST 除外)

【问题讨论】:

    标签: android redirect webview url-redirection


    【解决方案1】:

    当你在WebView上使用loadUrl时,它不会调用shouldoverrideurlloading,因为你不需要它,你可以决定是要WebView加载URL,还是要处理它在传递给WebView 之前,请自行决定。
    shouldoverrideurlloading 将在WebView 更改其 URL 时(不是您的意愿,而是例如当用户单击 WebView 中的链接或发生重定向。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-11
      • 2013-05-16
      • 2019-05-16
      • 1970-01-01
      • 1970-01-01
      • 2015-10-20
      相关资源
      最近更新 更多