Display content:// image fails before opening selector


#1

Hi all

I have an app that lets the user either take a photo and store it in the app directory, or select a photo that already exists on the camera.

I am using the Camera plugin

$scope.selectPhoto = function(){
		cameraOptions = {
			quality: 50,
			destinationType: Camera.DestinationType.FILE_URI,
			sourceType : Camera.PictureSourceType.PHOTOLIBRARY,
			encodingType: Camera.EncodingType.JPEG,
			cameraDirection: Camera.Direction.BACK
		};
		navigator.camera.getPicture( $scope.cameraSuccess, $scope.cameraError, cameraOptions );
	};

In $scope.cameraSuccess I set $scope.data.imageURI to the supplied URI which is a content:// type file, this updates an img with the following code and all works fine

<img ng-src="data.imageURI" />

data.imageURI gets saved to local storage when it changes and is loaded when the app is opened.

NOW, when I open the app from scratch, the app crashes when it tries to open <img ng-src="data.imageURI" /> which is the mentioned content:// URI supplied by the camera plugin when using sourceType : Camera.PictureSourceType.PHOTOLIBRARY

I’m not getting an error message, and from what I can tell from the ADB plugin / developer console there is no error output.

If data.imageURI is defined by taking a photo (that is, the URI is to a file in the app directory), the app does NOT crash.

The behaviour suggests to me that the app doesn’t have permission/an understanding of a content:// URI until after the Camera plugin has made a call to it.

Anyone seen similar to this? Is there anything I can do?

Thanks
-Chris