1. 程式人生 > >android webview訪問html報Cross origin requests are only supported for protocol schemes: http, data, ch

android webview訪問html報Cross origin requests are only supported for protocol schemes: http, data, ch

Android webview直接打包angular專案的html(file:///android_asset/www/assets/index.html),訪問時報

Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

解決:

    webView.getSettings().setAllowUniversalAccessFromFileURLs(true);

webView.getSettings().setAllowUniversalAccessFromFileURLs(

true);

webView.loadUrl("file:///android_asset/www/assets/index.html");

參考