You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The correct solution will probably be to implement a WebViewAssetLoader, as per https://developer.android.com/develop/ui/views/layout/webapps/load-local-content#assetloader . This would enable the customization of resource loading, and we could use the same mechanism to implement bespoke content loading schemes (e.g., loading content from a zip archive). Parity with WKWebView could be achieved through the WKNavigationDelegatedecidePolicyFor delegate.
For the time being, the only workaround is to manually load the contents of the file into memory and load the HTML, like so:
This is very limited, though, because peer resources (e.g., scripts, stylesheets, and images) will not be resolved, so the HTML must be completely self-contained.
The text was updated successfully, but these errors were encountered:
It is common to want to load a locally-bundled HTML resource and load it in a web view, like so:
This works in iOS, but on Android the load fails with the error:
The problem is that the Android web view doesn't automatically handle the
jar:file:
scheme.If Skip resources were bundles as Android resources (which they aren't: they are traditional Java resources), then we might be able to transform local file loads into
file://android_assets/
orfile://android_res/
schemes, but this is expressly recommended against at https://developer.android.com/develop/ui/views/layout/webapps/load-local-content#antipatternsThe correct solution will probably be to implement a
WebViewAssetLoader
, as per https://developer.android.com/develop/ui/views/layout/webapps/load-local-content#assetloader . This would enable the customization of resource loading, and we could use the same mechanism to implement bespoke content loading schemes (e.g., loading content from a zip archive). Parity withWKWebView
could be achieved through theWKNavigationDelegate
decidePolicyFor
delegate.For the time being, the only workaround is to manually load the contents of the file into memory and load the HTML, like so:
This is very limited, though, because peer resources (e.g., scripts, stylesheets, and images) will not be resolved, so the HTML must be completely self-contained.
The text was updated successfully, but these errors were encountered: