Skip to content
Advertisement

Java – WebView What event handles (watches) URL changes – Android

The app does a login to a web application using WebView. Once in the webview, the webview appears to handle everything for you as it should based on the user’s clicks. However I need to review on each event if the URL changes to a specific logout URL.

How can I return the user to the app itself when the user logs out on the web application within the webview? I do not want the webview to stay as the active view.

I have tried WebViewClient.shouldOverrideUrlLoading and View.OnTouchListsner.

The class I tried to implement public but it didn’t allow me.

JavaScript

Here’s the code before I want to call the method to check the URL;

JavaScript

Advertisement

Answer

This can help you: https://developer.android.com/reference/android/webkit/WebViewClient.html#onPageStarted(android.webkit.WebView, java.lang.String, android.graphics.Bitmap)

The event does not notify you when the url changes, but does when the page starts to load, at that point you only need to verify the current url.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement