getting WebView history from WebBackForwardList

て烟熏妆下的殇ゞ 提交于 2020-01-02 02:53:08

问题


How do i get the history of a WebView using the WebBackForwardList class? I looked at the documentation page but i could not understand it, is WebBackForwardList the proper way to access the history of WebView? I intend to parse the history to a ListView, I cannot find any examples of how to access the history of WebView, What is the proper method to get the history?


回答1:


On your webView instance, just use copyBackForwardList(), for example

WebBackForwardList wbfl = webView.copyBackForwardList();

Then setup a for-loop to scan the list, pull entries (e.g., title, URL), and send them to your ListView (or whatever).




回答2:


Yeah, you can use WebBackForwardList

Example:

public void getBackForwardList(){
    WebBackForwardList currentList = this.copyBackForwardList();
    int currentSize = currentList.getSize();
    for(int i = 0; i < currentSize; ++i)
    {
        WebHistoryItem item = currentList.getItemAtIndex(i);
        String url = item.getUrl();
        LOG.d(TAG, "The URL at index: " + Integer.toString(i) + " is " + url );
    }
}


来源:https://stackoverflow.com/questions/19365668/getting-webview-history-from-webbackforwardlist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!