Question

I try to load an image file from the phone. And by using the example code (Camera.sourceType = Camera.PictureSourceType.PHOTOLIBRARY), when a button is pressed, a popup showing that I can select to open "Photo Library" OR "File Manager" (some names like that, may differ across phone models and languages). I can get the returned image file if I select it via Photo Library (as the code indicated?), but failed if I use "File Manager". The error is saying "Unable to load local resources - file://....". (In contrast, the returned value from Photo Library is of the content:// protocol).

Since users may randomly use one of the applications (and some images are not in photo library scope), how can I get it correct with both ways?

=======Update========

Just realize that the error is reported because I use the returned file handle to the image as the image source. And my phonegap app use a remote link as index.html, which is thus not allowed to load local resources (cross-domain issue). So I need to upload it at background firstly and set the image source to the returned url instead...

Was it helpful?

Solution

Just as I updated, I use a remote page (e.g., http://domain.com/index.html) instead of a page in assets (e.g., index.html, in most PhoneGap documents and tutorials). So the file:// protocol will meet cross-domain restrictions and cannot be loaded by the remote page. While the content:// protocol has no such restrictions. I have to reorganize the architecture of my solution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top