I am making a dog whistle app using html5 to execute javascript and jquery webview.
The webview loads just fine but the Javascript fails to execute in my device on 7.0 and above.
With lollypop 5.0 and 5.5 devices, the javascript that the html calls works as expected. Everything compiles correctly.
The Logs do not log a thing on html5 button click after 7.0 when pushing the button to make the tone.
All of the files load locally from assets although I even enabled internet permissions. Is there a change at 7.0 which would stop javascript from working? Like I said before, everything works perfectly in lollypop. How would I fix?
Here is some code from my webview: EDITED: Nov 20 2019
WebView webView = (WebView) this.findViewById(R.id.webView);
WebSettings webSettings = webView.getSettings();
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
if (Build.VERSION.SDK_INT > 17) { webSettings.setMediaPlaybackRequiresUserGesture(false); }
String myurl="file:///android_asset/index.html";
webSettings.setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setDomStorageEnabled(true);
webView.setWebChromeClient(new WebChromeClient());
webView.setWebViewClient(new WebViewClient());
webSettings.setDefaultTextEncodingName("utf-8");
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.loadUrl(myurl);
Try adding WebViewClient
and WebChromeClient
for your browser.
webview.setWebViewClient(new MyWebViewClient());
webview.setWebChromeClient(new MyWebChromeClient());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.