Is there a way to access the history so that I know what URL the user is visiting when they hit the back button (which calls WebView.goBack())?
Android App Development for Beginners This example demonstrate about How to enable back button in android webview. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
Use shouldOverrideUrlLoading(WebView, WebResourceRequest) instead. if the tap in Webview is a link to custom URL, (like myurl://parameters), its not getting called.
The WebView class is an extension of Android's View class that allows you to display web pages as a part of your activity layout. It does not include any features of a fully developed web browser, such as navigation controls or an address bar. All that WebView does, by default, is show a web page.
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
This is probably the method you're looking for: WebView.copyBackForwardList
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