首页 > 解决方案 > Ionic cordova-plugin-camera 未在 Android 上打开图库

问题描述

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.

我的方法:

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);
     });
   }

任何帮助或建议将不胜感激。

标签: androidionic3cordova-plugin-camera

解决方案


这适用于我在 Android 中。

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

唯一的区别是当我得到结果时我不会清理文本。
我只是做this.myPicture = image64;

试试看,告诉我它是怎么回事。


推荐阅读