Unable to load the 360 (also VR) image in webView

1.1k Views Asked by At

I have a link to 360 Image for the mobile site but I want to load that in WebView in my App. Link works perfectly on the native mobile browser as well as Google Chrome, but not in the WebView in my App.

Any help is Appreciated. Thanks.

2

There are 2 best solutions below

0
On

Lately, but I think this will helpful to someone. In your activity using webview, set this in androidmanifests set: android:hardwareAccelerated="true" And my webview 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());

Try this, It will work perfectly!

0
On

We can load the 360 degree url(also vr) using the below webview settings.

    binding.webView.settings.javaScriptEnabled = true
    binding.webView.settings.allowFileAccess = true
    binding.webView.settings.pluginState = WebSettings.PluginState.ON
    binding.webView.settings.domStorageEnabled = true
    binding.webView.settings.allowContentAccess = true
    binding.webView.settings.loadsImagesAutomatically = true
    binding.webView.settings.blockNetworkImage = false
    binding.webView.webViewClient = object : WebViewClient() {
        override fun shouldOverrideUrlLoading(view: WebView, url: String?): Boolean {
            if (url != null) {
                view.loadUrl(url)
            }
            return true
        }

        override fun onPageFinished(view: WebView?, url: String?) {

        }
    }

    binding.webView.settings.javaScriptCanOpenWindowsAutomatically = true

    binding.webView.webChromeClient = WebChromeClient()
    binding.webView.loadUrl("url")