I want to display the a-frame in the Android webview.

Asked 2 years ago, Updated 2 years ago, 168 views

Web page using WebVR framework a-frame using WebGL,
I'm thinking of using webview to display it on the app instead of Android's Chrome app.

As a trial, I tried to display the official site of a-frame as shown below, but the screen is still white and nothing is displayed.

private WebView m_WebView;

@ Override
protected void onCreate (Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);


    m_WebView=(WebView) findViewById (R.id.vr_webView);

    m_WebView.getSettings().setJavaScriptEnabled(true);
    m_WebView.getSettings().setAllowFileAccessFromFileURLs(true);
    m_WebView.getSettings().setAllowUniversalAccessFromFileURLs(true);

    m_WebView.setWebChromeClient(newWebChromeClient());
    m_WebView.setWebViewClient(newWebViewClient());

    m_WebView.loadUrl("https://aframe.io");
}

The device used for verification is
·Xperia X Performance (Android 7.0)
·Galaxy S6 Edge (Android 6.0.1)
That's it.

Does anyone know the solution?
*The following log was displayed when running the application.

I/chromium: [INFO:CONSOLE(137)] "No DPDB device match." source: https://aframe.io/aframe/dist/aframe-master.min.js(137)
I/chromium: [INFO:CONSOLE(137)] "Failed to recalculate device parameters." source: https://aframe.io/aframe/dist/aframe-master.min.js(137)
I/chromium: [INFO:CONSOLE(137)] "Using fallback Android device measures." source: https://aframe.io/aframe/dist/aframe-master.min.js(137)
I/chromium: [INFO:CONSOLE(139)] "Failed to load viewer profile: %s", source: https://aframe.io/aframe/dist/aframe-master.min.js(139)
I/chromium: [INFO:CONSOLE(137)] "Uncaught TypeError: Cannot read property 'distributionCoeficients' of undefined", source: https://aframe.io/aframe/dist/aframe-master.min.js(137)
I/chromium: [INFO:CONSOLE(107)] "THREE.WebGLRenderer", source: https://aframe.io/aframe/dist/aframe-master.min.js(107)
I/chromium: [INFO:CONSOLE(137)] "No DPDB device match." source: https://aframe.io/aframe/dist/aframe-master.min.js(137)
I/chromium: [INFO:CONSOLE(137)] "Failed to recalculate device parameters." source: https://aframe.io/aframe/dist/aframe-master.min.js(137)
I/chromium: [INFO:CONSOLE(137)] "Using fallback Android device measures." source: https://aframe.io/aframe/dist/aframe-master.min.js(137)
I/chromium: [INFO:CONSOLE(139)] "Failed to load viewer profile: %s", source: https://aframe.io/aframe/dist/aframe-master.min.js(139)
I/chromium: [INFO:CONSOLE(137)] "Uncaught TypeError: Cannot read property 'distributionCoeficients' of undefined", source: https://aframe.io/aframe/dist/aframe-master.min.js(137)
I/chromium: [INFO:CONSOLE(137)] "Error loading online DPDB!", source: https://aframe.io/aframe/dist/aframe-master.min.js(137)
I/chromium: [INFO:CONSOLE(137)] "Error loading online DPDB!", source: https://aframe.io/aframe/dist/aframe-master.min.js(137)

android java webview

2022-09-30 21:24

2 Answers

It was easy to use Crosswalk instead of WebView.
Crosswalk deployment is here
http://qiita.com/niusounds/items/ecd51016cda91c5c3a5e


2022-09-30 21:24

Do you have the following permission entries in AndroidManifest.xml?

<uses-permission android:name="android.permission.INTERNET"/>

Xperia Ace (Android 9):

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extensions AppCompatActivity{

    @ Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        WebView webView = new WebView (this);

        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setAllowFileAccessFromFileURLs(true);
        webView.getSettings().setAllowUniversalAccessFromFileURLs(true);

        webView.setWebChromeClient(newWebChromeClient());
        webView.setWebViewClient(newWebViewClient());

        webView.loadUrl("https://aframe.io");

        setContentView (webView);
    }
}

Screenshot


2022-09-30 21:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.