Android Webview:知道网址重定向

时间:2013-07-23 06:34:43

标签: redirect android-webview

有没有方法可以知道在webview中加载的网址是redirecting还是其他网页?

E.g

  I have an Edittext where I search for "car" .Now , result page for "car" is 
 loaded in the webview below. In the result page , I click for wikipedia link.
 There, First url loaded is "https://en.wikipedia.org/wiki/Automobile" which 
  automatically gets redirected to "https://en.m.wikipedia.org/wiki/Automobile".
 I want to know this redirection.

Actually , I want to find whether the url loaded in webview is redirecting or not.
 If it's redirecting ,then,I want to capture it and take some actions.

提前谢谢。任何帮助都会很棒。

1 个答案:

答案 0 :(得分:4)

是的,请看WebViewClient.onPageStarted()。调用时(在每次重定向时),您可以通过WebView视图参数获取网址:view。getUrl()