有没有办法访问历史记录,以便我知道用户点击后退按钮(调用WebView.goBack())时访问的URL?
答案 0 :(得分:23)
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
答案 1 :(得分:16)
这可能是您正在寻找的方法:WebView.copyBackForwardList