For the purposes of this question, all that is really relevant about the app is that the use has the ability to do one of the following
When they select the photo, we want to display the image on the view.
This looks like the following:
The problem we are having is that when we test with Android, only the Take Photo
option works consistently, while the Select Photo
method will work if it is chosen from the same gallery where captured images are stored.
For example, by choosing Take Photo
- the image is stored at the following location
file://storage/emulated/0/Android/data/path.to.my.app/13124124/cache/segweg.jpeg
and the image shows up fine.However, if we choose to select an existing photo from the gallery and we choose from somewhere other than where images are stored from camera capture, the path looks like the following and does not work:
content://media/external/images/media/4430
The angular code looks like the following:
$scope.getPhoto = function() {
Camera.getPicture({
sourceType:1, //camera
destinationType:1, //file URI
saveToPhotoAlbum:false,
correctOrientation:true
}).then(function(imageURI) {
$scope.imageURI = imageURI; //ALWAYS WORKS
}, function(err) {
alert('An error has occured');
});
};
$scope.selectPhoto = function(){
Camera.getPicture({
sourceType:0, //photo album,
destinationType:1, //file URI
saveToPhotoAlbum:false,
correctOrientation:true
}).then(function(imageURI) {
$scope.imageURI = imageURI; //THIS ONLY WORKS SOMETIMES
}, function(err) {
alert('An error has occured');
});
};
and the markup in the template looks like the following:
<ion-view view-title="Photo">
<ion-content>
<p class="text-center" ng-click="selectPhoto()">
<span class="ion-image send-photo" ng-if="imageURI == undefined"></span>
<img ng-if="imageURI != undefined" ng-src="{{imageURI}}"></img>
</p>
<button class="button-red button button-block" ng-click="getPhoto()">
Take Photo
</button>
<button class="button-red button button-block" ng-click="selectPhoto()">
Select Photo
</button>
</ion-content>
</ion-view>
UPDATE
I ran adb logcat *:E
to see if anything turned up and saw the following error popup.
E/GalleryUtils(26145): Error while using the ContextProvider
E/GalleryUtils(26145): java.lang.IllegalArgumentException: Unknown URL content://com.samsung.android.providers.context.log.action.REPORT_APP_STATUS_SURVEY
E/ActivityThread(26145): Failed to find provider info for com.samsung.android.providers.context.log.action.REPORT_APP_STATUS_SURVEY