HarmonyOS 鸿蒙Next app调起手机图库是否还需获取权限
HarmonyOS 鸿蒙Next:app调起手机图库是否还需获取权限
app调起手机图库不用获取权限了吗?
‘ohos.permission.READ_MEDIA’, ‘ohos.permission.WRITE_MEDIA’,
调起方法如下:
const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
photoSelectOptions.maxSelectNumber = /* this.toolData.id === CommonConstants.FUN_ZIP ? 30 :*/ 1;
let photoViewPicker = new photoAccessHelper.PhotoViewPicker();
photoViewPicker.select(photoSelectOptions).then((photoSelectResult: photoAccessHelper.PhotoSelectResult) => {
let imgDatas = photoSelectResult.photoUris;
this.isGoFunPage(imgDatas);
Logger.info(TAG, ‘photoViewPicker.select to file succeed and uris are:’ + imgDatas);
}).catch((err: BusinessError) => {
Logger.error(TAG,
})
‘ohos.permission.READ_MEDIA’, ‘ohos.permission.WRITE_MEDIA’,
调起方法如下:
const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions();
photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE;
photoSelectOptions.maxSelectNumber = /* this.toolData.id === CommonConstants.FUN_ZIP ? 30 :*/ 1;
let photoViewPicker = new photoAccessHelper.PhotoViewPicker();
photoViewPicker.select(photoSelectOptions).then((photoSelectResult: photoAccessHelper.PhotoSelectResult) => {
let imgDatas = photoSelectResult.photoUris;
this.isGoFunPage(imgDatas);
Logger.info(TAG, ‘photoViewPicker.select to file succeed and uris are:’ + imgDatas);
}).catch((err: BusinessError) => {
Logger.error(TAG,
Invoke photoViewPicker.select failed, code is ${err.code}, message is ${err.message}
);})
2 回复
使用photoAccessHelper的方式获取图库,不需要申请acl权限,后续因为acl权限管控的问题,建议使用photoviewpicker的方式来拉起图库等
作为IT专家,对于HarmonyOS 鸿蒙Next系统中app调起手机图库是否需要获取权限的问题,可以给出以下专业解答:
在HarmonyOS NEXT系统中,应用调起手机图库确实需要获取相应的权限。HarmonyOS NEXT对图库的安全访问实施了全面强制措施,要求所有应用必须通过安全访问控件获取数据。这一措施旨在保护用户隐私和数据安全,防止未经授权的应用访问敏感信息。
因此,开发者在开发HarmonyOS NEXT应用时,需要确保应用具有访问图库的权限,并遵循系统提供的安全访问机制。这通常涉及在应用的权限设置中声明图库访问权限,并在用户首次使用时请求用户授权。
如果开发者在应用开发中遇到与图库访问权限相关的问题,可以查阅HarmonyOS NEXT的官方文档或开发者指南,以获取更详细的信息和指导。如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html。