I am working on an app which has an activity/fragment that displays web pages for certain sites. Android webview (chrome) is popping up alert dialogs for subscribing to push notifications in some of them, which is causing weird flashing/flickering issue.
This is the section for webview and it's settings
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(false);
webSettings.setDomStorageEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setAppCacheMaxSize(5 * 1024 * 1024);
webSettings.setAppCachePath("");
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webSettings.setUserAgentString(mUserAgent);
webView.setBackgroundColor(Color.argb(1, 0, 0, 0));
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
BaseWebViewFragment.this.onReceivedTitle(title);
}
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
progressChanged(view, newProgress);
}
});
I need to disable these popups completely but cannot find a way to do it.
I tried disabling JS completely, but it causes loading issue for some of the sites.
I also tried overriding the onJS...() methods for WebChromeClient and canceling/confirming the result but to no avail.
Whats the working approach for this?
from Disabling alert/popup for Android Webview ChromeClient
No comments:
Post a Comment