1. android中不支持h5中的audio標(biāo)簽
解決方案:
需要播放聲音只能通過video標(biāo)簽來實(shí)現(xiàn)
2.關(guān)于webview的本地存儲
解決方案:
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAppCachePath(Constants.FileCachePath);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAppCacheEnabled(true);
3.第一次進(jìn)入activity時webview正常,第二次進(jìn)入webview顯示空白,顯示的進(jìn)度到不了100
解決方案:
if (Build.VERSION.SDK_INT >= 11) {
? ? webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
4.關(guān)于webview加載本地資源和加載網(wǎng)絡(luò)資源同時進(jìn)行時效率降低
解決方案:
在webview加載網(wǎng)頁之前
if(Build.VERSION.SDK_INT >= 19) {
? ? ? ? webView.getSettings().setLoadsImagesAutomatically(true);
} else {
? ? ? ? webView.getSettings().setLoadsImagesAutomatically(false);
}
然后在onpagefinished方法里面做監(jiān)聽,當(dāng)頁面完成的時候再去做相應(yīng)的加載圖片
public void onPageFinished(WebView view, String url) {
? ? if(!webView.getSettings().getLoadsImagesAutomatically()) {
? ? ? ? webView.getSettings().setLoadsImagesAutomatically(true);
? ? }
}
5.修改webview加載錯誤的提示頁面類似404,403等頁面,讓原生來實(shí)現(xiàn)這個頁面,我們可以通過重寫onreceivederror方法
解決方案:
public void onReceivedError (WebView view, int errorCode, String description, String failingUrl) {
? ? super.onReceivedError(view, errorCode, description, failingUrl);
? ? loadDataWithBaseURL(null, "", "text/html", "utf-8", null);
? ? switch(errorCode){
? ? ? case 404:
? ? ? ? errorView.setBackgroundRes...(XXXXX);
? ? ? ? break;?
? ? }
? ? errorView.setVisibility(View.VISIBLE);
}