Slack local resource access restriction on Android 4.4.2 and feature versions?


#1

Hello,

so I’m workin mainly on Android 4.4.2. It seems to be a restriction of the os, that the webview chromium cannot access local resources.

Please assume, that I have a picture “mypic.png” in the download folder. I tested a simple local resource request, by setting an html image tag into a view, like:
<ion-content> <img src="file:///storage/emulated/0/Download/mypic.png" </ion-content>

Testing this with ionic run -l does not show the picture on an Android 4.4.2 device.

But testing this on an Android 4.3 device … here it works. On Android versions before 4.4.2 I have no restrictions to local resources.

Android 4.4.2 (+) has restrictions to local resources. The resources (like a png-image) cannot be accessed easily, like in past Android versions. How to slack this restriction?


#2

Resolved

And … here is the solution!

So it is EXPLICITLY needed to allow access to local file resource at Android 4.4+.

It is NOT enough to set following line ONLY to your config.xml:
<allow-navigation href="*"/>

You will have to set the next line on Android 4.4+, too:
<allow-navigation href="file://*/*" />

Dont forget for your index.html:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">

Regarding to http://stackoverflow.com/questions/30326148/cordova-ionic-http-request-not-processing-while-emulating-or-running-on-dev … I had a suspicion.