I have problem about ImagePicker with Android Standalone app.
- Press Button to Choose image file.
- Confirm select image.
- Edit resize image (But this step not working and skip to my app screen)
- Local image url is null.
And I search how to slove it. Finally I found problem in mycode. I see allowsEditing in options in my code is ‘True’ and orther function is ‘False’. But function ‘False’ is working (I mean that return data) !!! Why?.
I try to change allowsEditing: ''true" —> ‘false’. …it’s work.
But… I want to use allowsEditing function.
my code
export async function uploadImage(mode, options = null) {
var imageData = {};
var option = options || {
base64: true,
allowsEditing: true,
aspect: [1, 1],
}
if (mode === 'take') {
var { status: cameraPerm } = await Permissions.askAsync(Permissions.CAMERA);
var { status: cameraRollPerm } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
}
if ((mode === 'take' && cameraPerm === 'granted' && cameraRollPerm === 'granted') || mode === 'select') {
var pickerResult = {};
if (mode === 'take') {
pickerResult = await ImagePicker.launchCameraAsync(option)
}
else if (mode === 'select') {
pickerResult = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
...option
})
}
if (!pickerResult.cancelled) {
let fileExtension = pickerResult.uri.substr(pickerResult.uri.lastIndexOf('.') + 1);
imageData = {
LocalImage: pickerResult.uri,
image_extension: fileExtension,
image: 'data:image/' + fileExtension + ';base64,' + pickerResult.base64
}
return imageData;
} else {
return null
}
}
else if (cameraPerm !== 'granted') {
Alert.alert(
"แอพพลิเคชั่นนี้ไม่มีสิทธิเข้าถึงกล้องของคุณ",
"",
[
{
text: "ปิด",
onPress: () => { },
style: "cancel"
},
{
text: "ให้สิทธิการเข้าถึง",
style: 'default',
onPress: () => {
Linking.openURL('app-settings:')
}
}
],
{ cancelable: false })
}
}
Please provide the following:
- SDK Version:
- Platforms(Android/iOS/web/all): Android
Replace this section with as much relevant information as possible and any relevant code along with your question.