-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot take pictures on Android #416
Comments
How do you launch camera, can you share your code? What is your Android device/OS version information? |
Hey there! I'm having the same issue using Ionic. It works when using library but if I try to use the camera it gives the same error. function takePicture(camera) {
const options = {
// quality: 90, //Number Quality of the saved image, range of 0 - 100
destinationType: $cordovaCamera.DestinationType.FILE_URI, //Number Format of the return value
sourceType: camera ? $cordovaCamera.PictureSourceType.CAMERA : $cordovaCamera.PictureSourceType.PHOTOLIBRARY, //Number Set the source of the picture
allowEdit: false, //Boolean Allow simple editing of image before selection
encodingType: $cordovaCamera.EncodingType.JPEG, //Number JPEG = 0, PNG = 1
// targetWidth: 300, //Number Width to scale image (pixels). Used with targetHeight
// targetHeight: 300, //Number Height to scale image (pixels). Used with targetHeight
mediaType: $cordovaCamera.MediaType.PICTURE, //String Set the type of media to select from
cameraDirection: 0, //Number Back = 0, Front-facing = 1
// popoverOptions: "", //String iOS-only options that specify popover location in iPad
saveToPhotoAlbum: true, //Boolean Save image to photo album on the device
correctOrientation: true, //Boolean correct camera captured images in case wrong orientation
};
$cordovaCamera.getPicture(options).then(console.log).catch(console.error);
} Using Ionic v1 and Cordova:
Also as @Owlbertz , args passed to the Java-file:
|
So far I've located the problem on String partial_path = fullUri.split("external_files")[1]; The array does not split in two because the fullUri I have is In my case I've found this is due to other plugin, "cordova-open", which I use to open downloaded files. <paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths> while cordova-open establishes another in provider_paths.xml. <paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="files" path="."/>
<cache-path name="cache" path="."/>
<external-path name="external" path="."/>
<external-files-path name="external_files" path="."/>
<external-cache-path name="external_cache" path="."/>
</paths> I'm not really into the android environment, but I guess some conflict exists there. And for me to work I had to remove external-files-path & external-cache-path and specify external-path name with "external_files", same as in cordova-camera. Just naming them the same way caused another error afterwards on which the file were not found. If someone can point me into a better solution it would be appreciated. Maybe there should be something that checks the storage location, but I read something on the CordovaUri regarding there was no method to do it. |
I solved this question use this method https://github.com/apache/cordova-plugin-camera/pull/510/files/4f252dba55d27d08eb663ec51e2c86a983bc044a |
hi! thanks! |
Hi,
I am using the camera plugin to take pictures and to select photos from the gallery. While the latter works perfectly fine, the former action fails with this error:
length=1; index=1
I was able to find out the source, but not the cause:
Arguments provided were to the Java-file were:
0: 70
1: 1
2: 1
3: 1024
4: -1
5: 0
6: 0
7: false
8: true
9: false
10: null
11: 0
I hope someone has an idea what I am doing wrong.
The text was updated successfully, but these errors were encountered: