Inside my app, I was wondering if it was possible to make a certain URL in a WebView, when clicked, to redirect to a new activity view outside of the WebView?
Thanks!
Inside my app, I was wondering if it was possible to make a certain URL in a WebView, when clicked, to redirect to a new activity view outside of the WebView?
Thanks!
You can monitor events in a WebView
using a WebViewClient
. The method you want is shouldOverrideUrlLoading()
. This allows you to perform your own action when a particular URL is selected.
You set the WebViewClient
of your WebView
using the setWebViewClient()
method.
Alternatively, you could use a specific Intent
filter to "hijack" particular URLs. I think if you use this approach:
If you check out this link you will see an example of an Intent Filter being defined to launch an Activity. The website is set to call the callback URL when the user is done authenticating. This in turn gets handled by the browser and launches the Activity with the appropriate Intent Filter.