Ionic cordova-plugin-camera not opening gallery on Android

1k Views Asked by At

I'm trying to let user to select image from gallery on my ionic native app, code works on IOS but on android when select Choose Image nothing happend, can't see a error on logcat.

My method:

accessGallery(){
    this.camera.getPicture({
      sourceType: this.camera.PictureSourceType. SAVEDPHOTOALBUM,
      destinationType: this.camera.DestinationType.DATA_URL,
      quality: 10
     }).then((imageData) => {
        this.sanitizeImage('data:image/jpeg;base64,' + imageData);
      }, (err) => {
       console.log(err);
       this.showAlert("Cannot Access Gallery", err);
     });
   }

Any help or suggestion would be greatly appreciated.

1

There are 1 best solutions below

1
On

This works for me in Android.

 const options: CameraOptions = {
    quality: 10
    , destinationType: this.camera.DestinationType.DATA_URL
    , mediaType: this.camera.MediaType.PICTURE // Try this
    , sourceType: this.camera.PictureSourceType.PHOTOLIBRARY
 };

The only difference is that I don't sanitize the text when I get the result.
I just do this.myPicture = image64;

Try with that and tell me how it goes.