webview退出声音还在

boolean isOnPause;

在onPause里边

try {
    if (wb_webview != null) {
        wb_webview.onPause();
        isOnPause = true;
    }

} catch (Exception e) {
    e.printStackTrace();
}
在onResume里边

try {
    if (isOnPause) {
        if (wb_webview != null) {
            wb_webview.onResume();
        }
        isOnPause = false;
    }
} catch (Exception e) {
    e.printStackTrace();
}                                                                                                                                 

/**
 * 该处的处理尤为重要:
 * 应该在内置缩放控件消失以后,再执行mWebView.destroy()
 * 否则报错WindowLeaked
 */
@Override
public void onDestroyView() {

    if (wb_webview != null) {

        wb_webview.clearCache(true);
        wb_webview.clearHistory();

        layout_web.removeAllViews();
        wb_webview.setVisibility(View.GONE);
        wb_webview.removeAllViews();
        wb_webview.destroy();
        wb_webview = null;
    }

    isOnPause = false;

    super.onDestroyView();

}


webview 点击按钮失效的处理办法

wb_webview.requestFocusFromTouch();
wb_webview.requestFocus();
yWs = wb_webview.getSettings();
yWs.setPluginState(WebSettings.PluginState.ON);
yWs.setJavaScriptEnabled(true);
yWs.setSupportZoom(true);
yWs.setBuiltInZoomControls(true);
yWs.setUseWideViewPort(true);
yWs.setLoadWithOverviewMode(true);
yWs.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
yWs.setGeolocationEnabled(true);
yWs.setDomStorageEnabled(true);





你可能感兴趣的:(android)