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 void onPause() { super.onPause(); webView.onPause(); webView.pauseTimers();}@Overridepublic void onResume() { super.onResume(); webView.resumeTimers(); webView.onResume();}@Overrideprotected void onDestroy() { webView.destroy(); webView = null; super.onDestroy();}