Android WebView does not show javascript animation

I am trying to show a map that animates the percentages for several areas on the map. But javascript (which works in the browser) does not show animation or percentage at all. Webmpa.generateJs () generates javascript to animate percentages, and the initialize function is used to draw the map.

WebSettings settings = webView.getSettings(); settings.setAppCacheEnabled(true); settings.setDomStorageEnabled(true); settings.setDatabaseEnabled(true); settings.setJavaScriptEnabled(true); final WebMap webMap = new WebMap(); webView.addJavascriptInterface(webMap.getInterface(getActivity().getApplication(),this), "Android"); webView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { Log.d(TAG,webMap.generateJs()); webView.loadUrl("javascript:" + webMap.generateJs()); webView.loadUrl("javascript:initialize();"); } }); webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null); webView.setBackgroundColor(Color.TRANSPARENT); webView.loadUrl(MAP_URL); 
+5
source share
2 answers

You should use WebChromeClient for your purpose.

  webView.setWebChromeClient(new WebChromeClient()); 

It can help you.

+1
source

Just add a Satish answer, if you are using proguard, use this in your project proguard file:

 -keepclassmembers class fqcn.of.javascript.interface.for.webview { public *; } 
+1
source

All Articles