Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting WebView history from WebBackForwardList

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?

like image 810
user2835948 Avatar asked Oct 14 '13 17:10

user2835948


2 Answers

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).

like image 69
Scott Avatar answered Oct 19 '22 22:10

Scott


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 );
    }
}
like image 6
Prais Avatar answered Oct 19 '22 22:10

Prais