Hi, I’ve just recently started working with the new Google Pixel for testing my Ionic 2 Projects, and I’ve come across something peculiar.
When trying to capture a picture using the following:
......
import { Camera } from 'ionic-native';
......
Camera.getPicture({
quality : 75,
destinationType : 0,
sourceType : 1,
allowEdit : true,
targetWidth: 300,
targetHeight: 300,
saveToPhotoAlbum: false
}).then(imageData => {
this.base64Image = 'data:image/jpeg;base64,' + imageData;
console.log(this.base64Image);
}, error => {
console.log("ERROR -> " + JSON.stringify(error));
});
......
The Application crashes, causing an error:
ERROR → “file:///storage/emulated/0/Android/data/com.ionicframework.ionicApp144916/cache/.Pic.jpg exposed beyond app through ClipData.Item.getUri()”
Now from the devices I have access to, I have come to the conclusion that this error only occurs on the newer Android Nougat device as it works fine on the other devices I have which are running older versions of Android.
After some looking around, I discovered that the ‘file://’ destination is no longer usable in Android Nougat, because of Security issues.
So the easy fix would be to change:
destinationType : 0,
to something else right?.. Well not quite.
I have tried all 3 possible destinationType’s, and all return the exact same error. It’s almost as if Android is totally ignoring the the destinationType option, and just defaulting to ‘file://’, which isn’t even allowed anymore… I’m so confused…
Does anyone out there know a way around this so I can store the photo’s using ‘content://’ rather than ‘file://’ perhaps?