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() {
  }
}
相关推荐
一只大侠的侠13 分钟前
Flutter开源鸿蒙跨平台训练营 Day 5Flutter开发鸿蒙电商应用
flutter·开源·harmonyos
不爱吃糖的程序媛1 小时前
Capacitor:跨平台Web原生应用开发利器,现已全面适配鸿蒙
前端·华为·harmonyos
一只大侠的侠2 小时前
Flutter开源鸿蒙跨平台训练营 Day6ArkUI框架实战
flutter·开源·harmonyos
一只大侠的侠2 小时前
Flutter开源鸿蒙跨平台训练营 Day 4实现流畅的下拉刷新与上拉加载效果
flutter·开源·harmonyos
早點睡3903 小时前
高级进阶 ReactNative for Harmony 项目鸿蒙化三方库集成实战:react-native-drag-sort
react native·react.js·harmonyos
果粒蹬i3 小时前
【HarmonyOS】DAY9:利用React Native开发底部 Tab 开发实战:从问题定位到最佳实践
华为·harmonyos
lbb 小魔仙4 小时前
【HarmonyOS实战】OpenHarmony + RN:自定义 useForm 表单管理
harmonyos
早點睡3904 小时前
高级进阶 ReactNative for Harmony 项目鸿蒙化三方库集成实战:react-native-video
react native·华为·harmonyos
开开心心就好4 小时前
发票合并打印工具,多页布局设置实时预览
linux·运维·服务器·windows·pdf·harmonyos·1024程序员节
前端不太难5 小时前
HarmonyOS 游戏项目,从 Demo 到可上线要跨过哪些坑
游戏·状态模式·harmonyos