[英]Android 4.4 (KitKat) and newer Chromium webview load page incomplete
[英]Getting a Chromium WebView on Android 4.4?
我通過使用WebView將Web應用程序包裝在移動應用程序中。 我的應用程序使用僅在chrome瀏覽器中運行的音頻框架和webGL。 問題在於,默認情況下,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);
}
}
在您引用的鏈接中,所需的功能在WebView v36中,該功能僅在L-preview中可用,而在WebView v37 / Chromium M37中可用,如針對Android 5.0 Lollipop的Android開發者網站公告所述 。
由於您正在做音頻,因此模擬器可能無法正常工作,因此最好的選擇是在設備上進行測試。 將最低SDK設置為API 21,然后在裝有Android 5.0的設備上嘗試使用您的應用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.