Android中的WebView之loadDataWithBaseURL()与loadData()

WebView 加载数据的常用的几种方法如下:

public void loadUrl(String url, Map<String, String> additionalHttpHeaders) {

}

public void loadUrl(String url) {

}

public void postUrl(String url, byte[] postData) {

}

public void loadData(String data, String mimeType, String encoding) {

}

public void loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String historyUrl) {

}

代码示例:

webView.loadUrl(testUrl);

Map<String, String> additionalHttpHeaders = new HashMap<>();
additionalHttpHeaders.put("sso-sdk-client","sso-sdk");
webView.loadUrl(testUrl, additionalHttpHeaders);

webView.loadData(HTML_DATA, "text/html", "utf-8")

webView.loadDataWithBaseURL("about:blank", HTML_DATA, "text/html", "utf-8", null);