I have a webview in my android app.
I have loaded the url: https://imsnsit.org/imsnsit/notifications.php
There are links to various notifications. My WebView is doing nothing when I click on them.
It is working on everything else - Chrome (Android), Chrome(Desktop). The links are fine. One thing I notice notifications have the href with PHP file. Just navigating to that link does not work. I get Invalid operation. Plus the links are not static, they change everytime you refresh the page(only just the parameter for plum_url.php).
I am already using these functions. Nothing helps.webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setDomStorageEnabled(true);
I checked your link and all the links are opening a pdf file which is not supported in android web view. you can open such links in google docs or maybe some app in you device. Implement shouldOverrideUrlLoading something like this.
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if ( urlIsPDF(url)){
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), "application/pdf");
try{
view.getContext().startActivity(intent);
} catch (ActivityNotFoundException e) {
//user does not have a pdf viewer installed
}
} else {
webview.loadUrl(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