Webview - how to detect redirecting URLs
I have 开发者_运维知识库a question on the Android webview.
Assume URL A redirects to URL B at the server side.
My android application when it tries to open URL A in webview, it automatically redirects to URL B.
If a URL is being redirected to some other url, I see both these urls are stored in webview history. Now my webview history consists of [URL x, URL y, .... URL A, URL B ]
On back key click from URL B webpage, webview will try to load URL A, which again redirects to URL B. We need to double click back key twice rapidly, to go back beyond URL A
How do I solve this issue ? Is there a way to tell webview, not to put redirecting URLs in history or any other options ?
Thanks.
I'm not an expert but if you know the basic URL information of the sites you wish to ignore, maybe you can look into the doUpdateVisitedHistory
method for the WebViewClient
. You might be able to do something like:
@Override
public void doUpdateVisitedHistory(WebView view, String url,
boolean isReload) {
if ( url.contains("you.site") ) // do nothing
else super.doUpdateVisitedHistory(view, url, isReload);
}
精彩评论