HarmonyOS 权限申请拒绝后打开设置页面白屏?

代码如下:

let wantInfo = {
  action: 'action.settings.app.info',
  parameters: {
    settingsParamBundleName: 'com.example.test.template'
  }
} as Want;
let context = getContext() as common.UIAbilityContext;
context.startAbility(wantInfo).then((data)=>{
  console.info('前往授权页面成功', JSON.stringify(data));
}).catch(()=>{});
阅读 509
1 个回答

参考示例:

@Entry
@Component
struct Index {
  @State message: string = 'Hello World';
  aboutToAppear() {

  }

  startAbilityTest() {
    let context = getContext(this) as common.UIAbilityContext;
    let wantInfo: Want = {
      bundleName: 'com.huawei.hmos.settings',
      abilityName: 'com.huawei.hmos.settings.MainAbility',
      // uri: 'wifi_entry',
    };
    context.startAbility(wantInfo)
      .then(() => {
        // ...
      })
      .catch((err:Error) => {
        // console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
      });
  }

  build() {
    Row() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
          .onClick(()=>{
            this.startAbilityTest()
          })
      }
      .width('100%')
    }
    .height('100%')
  }
}

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进