Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android WebView not showing javascript animation

I am trying to show a map which animates percentages for several areas on the map. But the javascript (which works in the browser) doesn't show any animation or percentage at all. The webmpa.generateJs() generates the javascript to animate the percentages and the function initialize 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);
like image 504
Stefan Avatar asked Oct 30 '22 01:10

Stefan


1 Answers

You have to use WebChromeClient for your purpose.

 webView.setWebChromeClient(new WebChromeClient());

This may helps you

like image 50
Sathish Kumar J Avatar answered Nov 11 '22 11:11

Sathish Kumar J