I have a WebView on my application and some links which are URL adresses.
Some of them don’t have the baseURL, only something like “/abc/abc”
I would like to set the baseURL for all the links starting with “/”.
I have tryed this:
WebView wv = (WebView) findViewById(R.id.EditorialWebView);
wv.setBackgroundColor(0x00000000);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadDataWithBaseURL("", editorialBoard, "text/html", "utf-8", "");
wv.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView wv, String url) {
if (url.startsWith("/"))
{
wv.loadUrl("http://www.mdpi.com"+url);
}
return true;
}
});
But nothing happens.
Try something like this
Please let me know if it works for you as I am unable to test it at the moment.