Android WebView and WebGL

后端 未结 3 1079
醉话见心
醉话见心 2020-12-20 00:36

Android WebView: WebGL is not working on some devices

I use Webview in my android application. The task is to add WebGL interactive elements on the screen. Applicati

3条回答
  •  独厮守ぢ
    2020-12-20 00:40

    Late but I think this will be helpful to someone. In your activity using webView, set this in androidmanifests set: android:hardwareAccelerated="true". And my webView looks like this:

     webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setAllowFileAccess(true);
        webView.getSettings().setPluginState(WebSettings.PluginState.ON);
        webView.getSettings().setDomStorageEnabled(true);
        webView.getSettings().setAllowContentAccess(true);
        webView.getSettings().setLoadsImagesAutomatically(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            webView.getSettings().setAllowFileAccessFromFileURLs(true);
        }
        webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    
        webView.setWebChromeClient(new WebChromeClient());
    

提交回复
热议问题