当前位置: 首页 > news >正文

做网站主流技术设计参考图网站

做网站主流技术,设计参考图网站,湖南长沙有哪些大学,推广公司怎么做一. 权限分类 1. system_grant system_grant 为系统授权#xff0c;无需询问用户#xff0c;常用的权限包括网络请求、获取网络信息、获取wifi信息、获取传感器数据等。 /* system_grant#xff08;系统授权#xff09;*/static readonly INTERNET ohos.permission.INTE…一. 权限分类 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 ohos.permission.WRITE_IMAGEVIDEO // 图片视频-写static readonly READ_IMAGEVIDEO ohos.permission.READ_IMAGEVIDEO // 图片视频-读static readonly MEDIA_LOCATION ohos.permission.MEDIA_LOCATION // 多媒体-本地static readonly WRITE_AUDIO ohos.permission.WRITE_AUDIO // 音频-写static readonly READ_AUDIO ohos.permission.READ_AUDIO // 音频-读static readonly READ_MEDIA ohos.permission.READ_MEDIA // 文件-读static readonly WRITE_MEDIA ohos.permission.WRITE_MEDIA // 文件-写static readonly APP_TRACKING_CONSENT ohos.permission.APP_TRACKING_CONSENT // 广告标识符static readonly DISTRIBUTED_DATASYNC ohos.permission.DISTRIBUTED_DATASYNC // 多设备协同static readonly ACCESS_BLUETOOTH ohos.permission.ACCESS_BLUETOOTH // 使用蓝牙能力static readonly READ_PASTEBOARD ohos.permission.READ_PASTEBOARD // 剪贴板static readonly READ_HEALTH_DATA ohos.permission.READ_HEALTH_DATA // 健康数据static readonly ACTIVITY_MOTION ohos.permission.ACTIVITY_MOTION // 健身运动 二. 权限声明  1. system_grant 在应用 entry 模块的 module.json5 中添加权限声明。 requestPermissions: [{name: ohos.permission.INTERNET}, {name: ohos.permission.GET_NETWORK_INFO}, {name: ohos.permission.GET_WIFI_INFO} ] 2. user_grant 在应用 entry 模块的 module.json5 中添加权限声明。 requestPermissions: [{name: ohos.permission.LOCATION,reason: $string:PERMISSION_LOCATION,usedScene: {abilities: [EntryAbility],when:inuse}},{name: ohos.permission.APP_TRACKING_CONSENT,reason: $string:PERMISSION_TRACKING_CONSENT,usedScene: {abilities: [EntryAbility],when:inuse}} ] 三. 权限应用  1. system_grant 使用该类权限不需要弹窗让用户授权只需要判断一下该权限在应用中是否声明。 import { abilityAccessCtrl, bundleManager, PermissionRequestResult, Permissions, Want } from kit.AbilityKit;export class PermissionManager {async checkPermissions(): void {const bundleInfo: bundleManager.BundleInfo await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION)const tokenId bundleInfo.appInfo.accessTokenIdconst atManager abilityAccessCtrl.createAtManager()const state atManager.checkAccessTokenSync(tokenId, ohos.permission.INTERNET)if (state abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {console.log(网络请求可用)} else {console.log(网络请求不可用)}} } 2. user_grant 使用该类权限需要先判断用户是否授权先由用户授权之后再使用该类权限相关的能力。 import { abilityAccessCtrl, bundleManager, PermissionRequestResult, Permissions, common } from kit.AbilityKit;export class PermissionManager {async checkPermissions(): Promisevoid {const bundleInfo: bundleManager.BundleInfo await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION)const tokenId bundleInfo.appInfo.accessTokenIdconst atManager abilityAccessCtrl.createAtManager()const state atManager.checkAccessTokenSync(tokenId, ohos.permission.LOCATION)if (state abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {console.log(定位权限已开启)} else {const context AppStorage.get(ability_context) as common.UIAbilityContext // 在EntryAbility中存储AbilityContextconst result: PermissionRequestResult await atManager.requestPermissionsFromUser(context, [ohos.permission.LOCATION, ohos.permission.APPROXIMATELY_LOCATION])const authResults: Arraynumber result.authResultsconst grantStatus: boolean (authResults[0] 0)if (grantStatus) {console.log(定位权限已开启)} else {console.log(定位权限未开启)} }} } 3. notification 推送通知的权限是基于 notificationMananger 服务实现不同于 system_agent 和 user_agent。 import notificationManager from ohos.notificationManager;export class PermissionManager {async checkNotificationPermissions(): Promisevoid {let grantStatus await notificationManager.isNotificationEnabled()if (!grantStatus) {await notificationManager.requestEnableNotification()grantStatus await notificationManager.isNotificationEnabled()if (!grantStatus) {console.log(通知权限未开启)} else {console.log(通知权限已开启)}} else {console.log(通知权限已开启)}} } 4. 跳转到APP设置页 import bundleManager from ohos.bundle.bundleManager; import { common, Want } from kit.AbilityKit; import { BusinessError } from kit.BasicServicesKit;export class PermissionManager {async gotoSetting(): Promisevoid {const bundleFlags bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATIONconst bundleParam bundleManager.getBundleInfoForSelfSync(bundleFlags)const bundleId bundleParam.namelet wantInfo: Want {bundleName: com.huawei.hmos.settings,abilityName: com.huawei.hmos.settings.MainAbility,uri: application_info_entry,parameters: {pushParams: bundleId}}const context AppStorage.get(ability_context) as common.UIAbilityContext // 在EntryAbility中存储AbilityContextcontext.startAbility(wantInfo).catch((error: BusinessError) {console.error(startAbility-error: ${JSON.stringify(error)})})} } 源码参考 harmonyos-permission
http://www.yayakq.cn/news/5196/

相关文章:

  • 怎么做网站代理商无锡企业网站排名优化
  • 网站专题二级页怎么做广西南宁生活网
  • 海淀区企业网站建设thinkphp做网站有什么好处
  • 一手项目对接app平台seo如何选择网站标题
  • 冠辰网站建设网站页面好了怎么做后端
  • 公司网站开发模板建设集团摩托车
  • 深圳企业网站模板重庆市哪个区最繁华
  • wordpress站点字体修改西部数码网站管理助手错误
  • 如何禁止某ip访问网站网站网站建设设计
  • 建设企业网站平台主要的目的是界面设计模式读后感
  • 怎么用php做网站后台程序企业网站 优秀
  • 手机网站设计教育类模板夏天做那些网站致富
  • 旅游网站的设计方案怎么做网站设置密码
  • 徐州做网站xlec网站开发一级分销
  • 电信ip做的网站移动不能访问公司官网开发
  • 做暧暖网站江阳建设集团网站
  • 专业设计网站公司网站建设捌金手指花总四
  • 个人网站制作总体设计蓝色门户网站
  • 怎么给自己公司做网站wordpress开发软件
  • 劲松网站建设公司wordpress做导航站
  • 创新的做pc端网站网站免费视频
  • 在菲做平台网站500强企业网站有哪些
  • 百度网站搜索关键字河北邢台出大事啦
  • 亚马逊没有网站怎么做seo亚马逊雨林动物大全
  • 农产品网站开发背景四会网站建设
  • 网站推广都有哪些公司注册资金可以取出来吗
  • 做网站的公司怎么做业务上海营销型网站开发
  • 网站做网站做任务手机网店开店网站
  • 广州网站优化地址网络优化关键词
  • 查询注册过的网站wordpress 判断登录页面跳转