- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm trying to read photo data stored in the photo library on Android device (5.1).
I've tried to use window.resolveFileSystemURL for that, but it failed by the error code 1000.
How can I treat on this problem?
We can easily reproduce the problem by the following steps.
1. Create new project using XDK sample "Image Capture".
2. Add "File" plugin
3. Replace www/js/main.js by the code shown below;
4. Build the project and launch it on some Android 5.1 device
/*jslint sloppy:true, browser:true, devel:true, white:true, vars:true, eqeq:true, plusplus:true */ /*global $:false, intel:false*/ /** * This function runs once the page is loaded, but intel is not yet active */ var windowHeight; var init = function () { windowHeight=window.innerHeight; var currentpic = document.getElementById("slideshowpicid"); currentpic.onload=alignImageMiddle; }; window.addEventListener("load", init, false); /** * Prevent Default Scrolling */ var preventDefaultScroll = function(event) { // Prevent scrolling on this element event.preventDefault(); window.scroll(0,0); return false; }; window.document.addEventListener("touchmove", preventDefaultScroll, false); /** * Device Ready Code */ var fileSystem = null; var onDeviceReady=function(){ // called when Cordova is ready if( window.Cordova && navigator.splashscreen ) { // Cordova API detected navigator.splashscreen.hide() ; // hide splash screen } } ; document.addEventListener("deviceready", onDeviceReady, false); //Event listener for camera //document.addEventListener("intel.xdk.camera.picture.add",onSuccess); //document.addEventListener("intel.xdk.camera.picture.busy",onSuccess); //document.addEventListener("intel.xdk.camera.picture.cancel",onSuccess); var picturecount=0; function onSuccess(imageURI) { var pic1 = document.getElementById("photoone"); var pic2 = document.getElementById("phototwo"); var pic3 = document.getElementById("photothree"); var changebutton = document.getElementById("buttonid"); pic3.src = pic2.src; pic2.src = pic1.src; pic1.src = imageURI; if(picturecount>=2) { changebutton.innerHTML = "Make Slideshow"; changebutton.className = "button showbutton"; changebutton.onclick=makeslideshow; } picturecount++; window.resolveLocalFileSystemURL( imageURI, function(fileEntry) { var reader = new FileReader(); reader.onload = function(evt) { var result = evt.target.result; alert("read file bytes=" + result.byteLength); }; fileEntry.file(function(file) { alert("read file"); reader.readAsArrayBuffer(file); }); }, function(error) { alert("read file failed. " + JSON.stringify(error)); }); } function onFail(message) { alert("Picture failure: " + message); } //This function creates the slideshow of the captured pictures. function makeslideshow() { var changebutton = document.getElementById("buttonid"); var pic1 = document.getElementById("photoone"); var pic2 = document.getElementById("phototwo"); var pic3 = document.getElementById("photothree"); pic1.className="hide"; pic2.className="hide"; pic3.className="hide"; changebutton.innerHTML="Take Picture"; changebutton.className="button hide"; document.getElementById("imagecontent").className="show"; var currentpic = document.getElementById("slideshowpicid"); currentpic.src=pic1.src; } function alignImageMiddle(){ var currentpic = document.getElementById("slideshowpicid"); var height = window.innerHeight; currentpic.style.marginTop=(height-currentpic.offsetHeight)/2+"px"; } /** * The following functions could be a single function that moves forwards or backwards. * For the demo we want users to be able to see exactly what is going on */ //Move to the next picture. If we are at the last picture, we jump to the first. function Next() { var pic1 = document.getElementById("photoone"); var pic2 = document.getElementById("phototwo"); var pic3 = document.getElementById("photothree"); var currentpic = document.getElementById("slideshowpicid"); var currentsrc = currentpic.src; if(currentsrc===pic1.src) { document.getElementById("slideshowpicid").src=pic2.src; } else if(currentsrc===pic2.src) { document.getElementById("slideshowpicid").src=pic3.src; } else { document.getElementById("slideshowpicid").src=pic1.src; } } //Move to previous picture. If we are at the first picutre, we jump to the last. function Previous() { var pic1 = document.getElementById("photoone"); var pic2 = document.getElementById("phototwo"); var pic3 = document.getElementById("photothree"); var currentsrc = document.getElementById("slideshowpicid").src; if(currentsrc===pic1.src) { document.getElementById("slideshowpicid").src=pic3.src; } else if(currentsrc===pic2.src) { document.getElementById("slideshowpicid").src=pic1.src; } else { document.getElementById("slideshowpicid").src=pic2.src; } } //Functionality to end the slideshow function endslideshow() { document.getElementById("imagecontent").className="hide"; picturecount=0; var pic1 = document.getElementById("photoone"); var pic2 = document.getElementById("phototwo"); var pic3 = document.getElementById("photothree"); var changebutton = document.getElementById("buttonid"); pic1.className=""; pic2.className=""; pic3.className=""; pic1.src="images/EmptyBox-Phone.png"; pic2.src="images/EmptyBox-Phone.png"; pic3.src="images/EmptyBox-Phone.png"; changebutton.onclick=takepicture; changebutton.className="button"; } //Camera button functionality function takepicture() { navigator.camera.getPicture(onSuccess, onFail, { quality: 50, sourceType: navigator.camera.PictureSourceType.SAVEDPHOTOALBUM, destinationType: navigator.camera.DestinationType.NAVITE_URI, encodingType: navigator.camera.EncodingType.JPEG }); }
Regards,
--
tetsuya
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like this may be the same problem you're having > http://stackoverflow.com/questions/30640251/cordova-resolvelocalfilesystemurl-error-code-1000-in-android
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Paul.
Thank you for your quick answer!
The sample project became working fine by downgrading Cordova CLI version to 4.1.2.
I will take this workaround until fixed version of Cordova is included in XDK.
Regards,
--
tetsuya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tetsuya -- the next release will include Cordova CLI 5.4.1+ (see specifics here > https://software.intel.com/en-us/xdk/faqs/cordova#cordova-version) which would be the best option to try. It is very close to the latest version of Cordova.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Paul,
Good news!
I'm looking forward to that.
Regards,
--
tetsuya

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page