android - 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);
});
}
任何帮助或建议将不胜感激。
解决方案
这适用于我在 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;
试试看,告诉我它是怎么回事。
推荐阅读
- redis - redis中调用expire或pexpire时,时间是否向上取整?
- java - 警报管理器无法唤醒
- asp.net - 通过外键添加与用户 ID 相关联的位置
- stripe-payments - customer.subscription.updated 是处理订阅状态的好方法吗?
- unity3d - 尝试为动作捕捉动画 FBX 选择 Humanoid Rig 时,“头像创建失败:未找到为人体骨骼 'Hips' 转换 'Hips'”
- python - 自动更正python库抛出错误而不是更正单词
- html - HTML和CSS中按钮的奇怪不想要的行为
- javascript - 将(单击)事件处理程序直接添加到 mat-step?
- html - 如何创建一个动态调整大小以适应用户屏幕的网格
- java - Android的Java下的属性声明范式