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?
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).
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 );
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With