【发布时间】:2014-12-17 03:51:04
【问题描述】:
我正在使用 WebView 将 Web 应用程序包装在移动应用程序中。我的应用程序使用音频框架和 webGL,它们都只在 chrome 浏览器中运行。问题是 WebView 默认是 android 系统浏览器。我的音频库和 webGL 不能在系统浏览器中运行,只能在 chrome 中运行。我知道有一种方法可以在 Android 应用程序中获取基于 chrome 的 WebView,因为他们在这里引用它:
https://developer.chrome.com/multidevice/webview/overview
有谁知道如何让 WebView 成为基于 chrome 的?下面是我的 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);
}
}
【问题讨论】:
标签: javascript android google-chrome webview