The application i'm developing has a webview, i need to capture webview request click events(eg: click on a link, click on a button, click on a youtube video play button such as...)
This can be done
you have to set a WebViewClient
to your WebView. this is how to do that.
WebView webView;//make sure to initialize
webView.setWebViewClient(webViewClient);
WebViewClient webViewClient= new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url){
return true;
}
@Override
public void onLoadResource(WebView view, String url){
if( url.equals("http://yoururl.com") ){
// do something
}
}
}
use this code it's work for me
webview.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
return true;
}
});
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