Get last loaded url of webview without doing a webView.goBack() in Android

Arnab Chakraborty picture Arnab Chakraborty · Oct 13, 2011 · Viewed 17.9k times · Source

I want to log the history url or last loaded url without manually storing the history urls. Is that possible?

Answer

Arnab Chakraborty picture Arnab Chakraborty · Oct 14, 2011

Found the answer in the docs ...

WebBackForwardList mWebBackForwardList = mWebView.copyBackForwardList();
String historyUrl = mWebBackForwardList.getItemAtIndex(mWebBackForwardList.getCurrentIndex()-1).getUrl();