HarmonyOS-权限管理

一. 权限分类

 1. system_grant

system_grant 为系统授权,无需询问用户,常用的权限包括网络请求、获取网络信息、获取wifi信息、获取传感器数据等。

/* system_grant(系统授权)*/
  static readonly INTERNET = 'ohos.permission.INTERNET' // 网路请求
  static readonly GET_NETWORK_INFO = 'ohos.permission.GET_NETWORK_INFO' // 网络信息-读
  static readonly GET_WIFI_INFO = 'ohos.permission.GET_WIFI_INFO' // WIFI信息-读
  static readonly GYROSCOPE = 'ohos.permission.GYROSCOPE' // 陀螺仪传感器
  static readonly ACCELEROMETER = 'ohos.permission.ACCELEROMETER' // 加速度传感器

2. user_grant

user_grant 是需要用户授权的权限,常用的权限包括定位、相机、麦克风、日历、文件读写等。

/* user_grant(用户授权)*/
  static readonly LOCATION = 'ohos.permission.LOCATION' // 定位-精确
  static readonly APPROXIMATELY_LOCATION = 'ohos.permission.APPROXIMATELY_LOCATION' // 定位-模糊
  static readonly LOCATION_IN_BACKGROUND = 'ohos.permission.LOCATION_IN_BACKGROUND' // 定位-后台
  static readonly CAMERA = 'ohos.permission.CAMERA' // 相机
  static readonly MICROPHONE = 'ohos.permission.MICROPHONE' // 麦克风
  static readonly READ_CONTACTS = 'ohos.permission.READ_CONTACTS' // 通讯录-读
  static readonly WRITE_CONTACTS = 'ohos.permission.WRITE_CONTACTS' // 通讯录-写
  static readonly READ_CALENDAR = 'ohos.permission.READ_CALENDAR' // 日历-读
  static readonly WRITE_CALENDAR = 'ohos.permission.WRITE_CALENDAR' // 日历-写
  static readonly WRITE_IMAGEVIDEO = &#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值