Kitkat kills: Not allowed to load local resource: file:///android_asset/webkit/android-weberror.png

后端 未结 8 1086
半阙折子戏
半阙折子戏 2020-11-30 03:54

I have an app that uses WebViews. I\'ve changed my targetAPI from 18 to 19 and I\'m currently testing on the new 4.4. For some reason I\'m getting this error: Not allo

8条回答
  •  生来不讨喜
    2020-11-30 04:44

    Not available at the time, this now works (though it's not recommended):

    webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    

    Here's what the doc says about setMixedContentMode:

    Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. By default, apps that target KITKAT or below default to MIXED_CONTENT_ALWAYS_ALLOW. Apps targeting LOLLIPOP default to MIXED_CONTENT_NEVER_ALLOW. The preferred and most secure mode of operation for the WebView is MIXED_CONTENT_NEVER_ALLOW and use of MIXED_CONTENT_ALWAYS_ALLOW is strongly discouraged.

    However, this might not answer the original question; it looks like the restriction only started with Lollipop.

提交回复
热议问题