I'm working with Android 5.0 and the last update of the WebView component. I try to embed a remote website (I can't modify this website source code) into a WebView.
My code below
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.contains(URL_SERVLET)) {
//Do nothing
Log.d("DEBUG", "load IMAGE");
//view.stopLoading();
} else {
Log.d("DEBUG", "load URL into WebView");
view.loadUrl(url);
}
return true;
}
// Called when all page resources loaded
public void onPageFinished(WebView view, String url) {
webView.setVisibility(View.VISIBLE);
splashscreenLayout.setVisibility(View.GONE);
}
});
On the website side, I get a button which open another url (using javascript) inside a popup. When I click on it via the Android Webview, this new URL replace the current one in the webview. I just want that nothing happened when I click on this button.
It works with this code: this url is not loaded. But the webview become white, like a blank screen.
I tried to call stopLoading(), doesn't do the trick.
I can't call webview.reload() because the remote website is written in jsp with one url which provide (generate on the fly I guess) html page. If I call reload(), the WebView is reinitialize to the first page (login page).
I also tried to save webview state and restore it, but it is not working.
Is there a way to "block" a changing of url and keep the webview pointing on the first url without reload?