android WebView js加载本地文件的跨域问题

webview 添加

        try {
            Class clazz = mWebView.getSettings().getClass();
            Method method = clazz.getMethod(
                    "setAllowUniversalAccessFromFileURLs", boolean.class);
            if (method != null) {
                method.invoke(mWebView.getSettings(), true);
            }
        } catch (IllegalArgumentException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }

你可能感兴趣的:(android WebView js加载本地文件的跨域问题)