Closed AsfanUlla closed 6 years ago
What do you want to achieve exactly?
Just showing a single page where the user can neither navigate forwards nor backwards from?
If so, try overriding shouldOverrideUrlLoading
in a custom WebViewClient
and always return true
from there.
shouldOverrideUrlLoading not working
private void loadWebView(AdvancedWebView webView, String htmlString){
try{
WebViewClient webViewClient = new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return true;
}
};
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.setWebViewClient(webViewClient);
webView.setDesktopMode(false);
webView.loadDataWithBaseURL("file:///android_asset/", htmlString, "text/html", "utf-8", "");
} catch(Exception e){
e.printStackTrace();
}
}
@hitesh-shukla What’s not working exactly? Can you print log statements to see if the shouldOverrideUrlLoading
method is actually called? Further, can you replace AdvancedWebView
with just WebView
everywhere and comment out the non-existing function calls afterwards, reducing this to a minimal example? Does it work then?
How can i disable navigation in the webview