1、设置webview属性:
webView.setWebChromeClient(new MyWebChromeClient());
webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setPluginState(WebSettings.PluginState.ON);
webSettings.setUseWideViewPort(true);
webSettings.setAllowFileAccess(true);
webSettings.setSupportZoom(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
webSettings.setUseWideViewPort(true);
webView.addJavascriptInterface(new JavaScriptObject(this), "android");
2、设置AndroidManifest.xml:
//开启硬件加速
3、关闭界面任在播放的问题:
@Overridepublic voidonPause() {
super.onPause();webView.onPause();webView.pauseTimers();}
@Overridepublic voidonResume() {
super.onResume();webView.resumeTimers();webView.onResume();}
@Overrideprotected voidonDestroy() {
webView.destroy();webView= null;super.onDestroy();}