diff --git a/LocationKit/entry/src/main/ets/pages/ApplyPrecisePositioning.ets b/LocationKit/entry/src/main/ets/pages/ApplyPrecisePositioning.ets index 4b91243305a0b3001a991a28760baa462d910bbd..b24e4549b3a9554068996573d1cc038ff1d1a5d0 100644 --- a/LocationKit/entry/src/main/ets/pages/ApplyPrecisePositioning.ets +++ b/LocationKit/entry/src/main/ets/pages/ApplyPrecisePositioning.ets @@ -17,7 +17,7 @@ * FAQ:如何申请精确定位 */ -// DocsCode 1 +// [Start apply_precise_positioning] import { abilityAccessCtrl, common, PermissionRequestResult, Permissions } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -32,20 +32,20 @@ export struct ApplyPrecisePositioning { reqPermissionsFromUser(permissions: Array): void { let context: Context = getContext(this) as common.UIAbilityContext; let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); - // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗 + // RequestPermissionsFromUser will determine whether to trigger a pop-up window based on the authorization status of the permission atManager.requestPermissionsFromUser(context, permissions).then((data: PermissionRequestResult) => { let grantStatus: Array = data.authResults; let length: number = grantStatus.length; for (let i = 0; i < length; i++) { if (grantStatus[i] === 0) { - // 用户授权,可以继续访问目标操作 + // User authorization allows continued access to the target operation } else { - // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限 - this.getUIContext().getPromptAction().showToast({ message: '用户拒绝授权' }); + // The user refuses authorization, prompting the user that authorization is required to access the functionality of the current page, and guiding the user to open the corresponding permissions in the system settings + this.getUIContext().getPromptAction().showToast({ message: 'User refuses authorization' }); return; } } - // 授权成功 + // Authorization successful }).catch((err: BusinessError) => { console.error(`Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`); }) @@ -54,4 +54,4 @@ export struct ApplyPrecisePositioning { build() { } } -// DocsCode 1 \ No newline at end of file +// [End apply_precise_positioning] \ No newline at end of file