HarmonyOS 在申请相机权限拒绝后仍能打开相机

HarmonyOS
2024-12-27 14:59:22
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
superinsect

使用cameraPicker的话不需要申请权限即可使用

import { BusinessError } from '@ohos.base';

@Entry
@Component
struct Permission_cameraPicker {
  mContext = getContext(this) as common.Context;

  async Permission_cameraPicker_demo() {
    try {
      let pickerProfile: picker.PickerProfile = { cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK };
      let pickerResult: picker.PickerResult =
        await picker.pick(this.mContext, [picker.PickerMediaType.PHOTO, picker.PickerMediaType.VIDEO], pickerProfile);
      console.log("the pick pickerResult is:" + JSON.stringify(pickerResult));
    } catch (error) {
      let err = error as BusinessError;
      console.error(`the pick call failed. error code: ${err.code}`);
    }
  }

  @State message: string = 'Hello World';

  build() {
    Row() {
      Column() {
        Button(this.message).onClick(() => {
          this.Permission_cameraPicker_demo()
        })
      }.width('100%')
    }.height('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
分享
微博
QQ
微信
回复
2024-12-27 17:31:53
相关问题
HarmonyOS 权限申请拒绝问题
911浏览 • 1回复 待解决
打开相机:直接使用相机拍照能力
2512浏览 • 1回复 待解决
HarmonyOS 相机权限问题
1370浏览 • 1回复 待解决
HarmonyOS 申请应用跟踪权限被直接拒绝
1034浏览 • 1回复 待解决
HarmonyOS 相机权限问题咨询
655浏览 • 1回复 待解决
HarmonyOS APP无法打开相机拍照
1168浏览 • 1回复 待解决
HarmonyOS如何代码实现打开相机应用
1266浏览 • 1回复 待解决
HarmonyOS 相机打开闪光灯设置无效
1936浏览 • 1回复 待解决
HarmonyOS 相机打开之后如何切换摄像头
1363浏览 • 1回复 待解决