HarmonyOS —— 跳转应用详情页

一、跳转应用详情页

鸿蒙跳转应用详情页功能,使用场景可以是引导用户进入应用详情页授予应用权限。

TypeScript 复制代码
  gotoAppDetail(context:common.UIAbilityContext){

    let bundleName = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT).name

    let wantInfo: Want = {
      bundleName: 'com.huawei.hmos.settings',
      abilityName: 'com.huawei.hmos.settings.MainAbility',
      uri: 'application_info_entry',
      parameters: {
        pushParams: bundleName // 打开指定应用的详情页面
      }
    }
    context.startAbility(wantInfo)
  }

二、如何获取 UIAbilityContext

1.在 UIAbility 中获取

TypeScript 复制代码
import UIAbility from '@ohos.app.ability.UIAbility';
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
import Want from '@ohos.app.ability.Want';

export default class EntryAbility extends UIAbility {
  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
    // 获取UIAbility实例的上下文
    let context = this.context;
  }
}

2.在页面中获取

TypeScript 复制代码
import common from '@ohos.app.ability.common';
import Want from '@ohos.app.ability.Want';

@Entry
@Component
struct Index {
  private context = getContext(this) as common.UIAbilityContext;

  // 页面展示
  build() {
  }
}
相关推荐
baobao熊6 小时前
【HarmonyOS】时间处理Dayjs
华为·harmonyos
GZ_TOGOGO6 小时前
【2024最新】华为HCIE认证考试流程
大数据·人工智能·网络协议·网络安全·华为
zhongcx11 小时前
鸿蒙应用示例:DevEco Testing 工具的常用功能及使用场景
harmonyos
@海~涛13 小时前
鸿蒙OpenHarmony
华为·harmonyos
zhongcx18 小时前
鸿蒙应用示例:镂空效果实现教程
harmonyos
训山19 小时前
【11】纯血鸿蒙HarmonyOS NEXT星河版开发0基础学习笔记-模块化语法与自定义组件
笔记·学习·华为·harmonyos·鸿蒙系统
helloxmg20 小时前
鸿蒙harmonyos next flutter混合开发之开发package
flutter·华为·harmonyos
zhongcx2 天前
鸿蒙应用示例:ArkTS UI框架中的文本缩进技巧
harmonyos
东林知识库2 天前
鸿蒙NEXT开发-自定义构建函数(基于最新api12稳定版)
华为·harmonyos
裴云飞2 天前
鸿蒙性能优化之布局优化
性能优化·harmonyos