Retrieving WebView History from WebBackForwardList

How to get WebView history using WebBackForwardList class? I looked at the documentation page, but I couldn’t understand it, is WebBackForwardList the right way to access WebView history? I am going to analyze the history in ListView, I can not find examples of how to access the history of WebView. What is the right method to get the story?

+6
source share
2 answers

In your webView instance just use copyBackForwardList () like

WebBackForwardList wbfl = webView.copyBackForwardList ();

Then configure the for-loop to scan the list, pull out the entries (e.g. title, URL) and send them to the ListView (or something else).

+12
source

Yes 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 ); } } 
0
source

Source: https://habr.com/ru/post/955925/


All Articles