简体   繁体   English

在Android 4.4上获取Chromium WebView?

[英]Getting a Chromium WebView on Android 4.4?

I'm wrapping a web application in a mobile app by using a WebView. 我通过使用WebView将Web应用程序包装在移动应用程序中。 My application uses an audio framework, and webGL that both only run in the chrome browser. 我的应用程序使用仅在chrome浏览器中运行的音频框架和webGL。 The problem is that the WebView is, by default, the android system browser. 问题在于,默认情况下,WebView是android系统浏览器。 My audio library and webGL don't work in the system browser, just in chrome. 我的音频库和webGL不能在系统浏览器中使用,而只能在chrome中使用。 I know there's a way to get a chrome-based WebView in an Android application because they reference it here: 我知道有一种方法可以在Android应用程序中获取基于Chrome的WebView,因为他们在这里引用了它:

https://developer.chrome.com/multidevice/webview/overview https://developer.chrome.com/multidevice/webview/overview

Does anyone know how to get the WebView to be chrome based? 有谁知道如何使WebView基于chrome? Below is my mainActivity.java code. 下面是我的mainActivity.java代码。

public class MainActivity extends ActionBarActivity {

    private WebView mWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        String url = "http://www.cs.stolaf.edu/users/lipson/MusicVisualization/musicVis.html";
        mWebView = (WebView) findViewById(R.id.webView1);

        mWebView.setWebChromeClient(new WebChromeClient());
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.setWebViewClient(new WebViewClient());
        mWebView.loadUrl(url);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

From the link you referenced, the features you want are in WebView v36 which was only available in the L-preview and are available in WebView v37/Chromium M37 as announced on the Android Developer website announcement for Android 5.0 Lollipop . 在您引用的链接中,所需的功能在WebView v36中,该功能仅在L-preview中可用,而在WebView v37 / Chromium M37中可用,如针对Android 5.0 LollipopAndroid开发者网站公告所述

Since you are doing audio, the emulator may not work so you best bet is to test on a device. 由于您正在做音频,因此模拟器可能无法正常工作,因此最好的选择是在设备上进行测试。 Set your minimum SDK to API 21 and try your app on a device with Android 5.0. 将最低SDK设置为API 21,然后在装有Android 5.0的设备上尝试使用您的应用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM