Is there any way to intercept javascript triggered URL in a WebView just like normal hrefs using shouldOverrideUrlLoading()?
1 Answer
onLoadResource() is called when any resource is being called, including JavaScript. The purpose is a bit different though than shouldOverrideUrlLoading().
webControls.setWebViewClient(new WebViewClient() { //Notify the host application that the WebView will load //the resource specified by the given url. @Override public void onLoadResource (WebView view, String url) { super.onLoadResource(view, url); Log.v(TAG, "onLoadResource("+url+");"); } //Give the host application a chance to take over the //control when a new url is about to be loaded in the //current WebView. @Override public void shouldOverrideUrlLoading(WebView view, String url) { super.shouldOverrideUrlLoading(view, url); Log.v(TAG, "shouldOverrideUrlLoading("+url+");"); } }