问题
Is there a way to access the history so that I know what URL the user is visiting when they hit the back button (which calls WebView.goBack())?
回答1:
This is probably the method you're looking for: WebView.copyBackForwardList
回答2:
String historyUrl="";
myWebView = (WebView) findViewById(R.id.webViewContent);
WebBackForwardList mWebBackForwardList = myWebView.copyBackForwardList();
if (mWebBackForwardList.getCurrentIndex() > 0)
historyUrl = mWebBackForwardList.getItemAtIndex(mWebBackForwardList.getCurrentIndex()-1).getUrl();
// Previous url is in historyUrl
来源:https://stackoverflow.com/questions/7813914/android-webview-is-there-a-way-to-know-what-the-previous-url-is