中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
微信扫码分享
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import { BusinessError } from '@ohos.base'; import common from '@ohos.app.ability.common'; let atManager = abilityAccessCtrl.createAtManager(); try { let context: Context = getContext(this) as common.UIAbilityContext; atManager.requestPermissionsFromUser(context, ["ohos.permission.CAMERA"]).then((data) => { console.info("data:" + JSON.stringify(data)); console.info("data permissions:" + data.permissions); console.info("data authResults:" + data.authResults); console.info("data dialogShownResults:" + data.dialogShownResults); }).catch((err: BusinessError) => { console.error("data:" + JSON.stringify(err)); }) } catch(err) { console.error(`catch err->${JSON.stringify(err)}`); }