【HarmonyOS NEXT】鸿蒙跳转华为应用市场目标APP下载页

【HarmonyOS NEXT】鸿蒙跳转华为应用市场目标APP下载页

一、问题背景:

如今,大家都离不开各种手机应用。随着鸿蒙系统用户越来越多,大家都希望能在鸿蒙设备上快速找到想用的 APP。华为应用市场里有海量的 APP,但之前从鸿蒙设备进入应用市场找特定 APP 的过程有点繁琐。

从开发角度来说,打通鸿蒙设备到华为应用市场目标 APP 下载页的直接跳转,能优化整个开发链路。从产品需求出发,这能提升应用分发的效率,助力产品推广。

站在用户体验方面,这么做能大大节省用户找 APP 的时间,让大家更快下载想用的应用,极大地提升用户使用鸿蒙设备获取应用的体验。所以,实现这个跳转功能十分必要。

二、解决方案:

源码示例如下,以跳转到华为应用市场的wx界面举例:

跳转目标app的下载页,需要知道其包名即可。 点击跳转按钮后的效果:

dart 复制代码
import Want from '@ohos.app.ability.Want';
import common from '@ohos.app.ability.common';
import { BusinessError } from '@kit.BasicServicesKit';

@Entry
@Component
struct AGCStorePage {
  private TAG: string = "AGCStorePage";

  // 以wx举例:
  @State mAppId: string = 'com.tencent.wechat';
  controller: TextInputController = new TextInputController();

  build() {
    Row() {
      Column() {
        TextInput({ text: this.appId, placeholder: '请输入应用的appId', controller: this.controller })
          .width('90%')
          .onChange((value: string) => {
            this.mAppId = value
          })

        Button('点击跳转到鸿蒙版应用市场详情页面')
          .margin({top: 50})
          .onClick(()=>{
            const want: Want = {
              uri: "store://appgallery.huawei.com/app/detail?id=" + this.mAppId
            };
            const context = getContext(this) as common.UIAbilityContext;
            context.startAbility(want).then(()=>{
              //拉起成功
              console.log(this.TAG, "跳转成功!");
            }).catch((err: BusinessError)=>{
              // 拉起失败
              console.log(this.TAG, "跳转失败!" + JSON.stringify(err));
            });
          })
      }
      .width('100%')
    }
    .height('100%')
  }
}

注意: 拼接分享的应用下载页链接为(以wx举例,替换id即可跳转到目标app): appgallery.huawei.com/app/detail?...

在鸿蒙设备上加载该链接,为自动跳转到应用市场app下载页。若不是鸿蒙设备,会提示:

相关推荐
钛态3 小时前
Flutter 组件 ews 的适配 鸿蒙Harmony 实战 - 深度对接企业级 Exchange 服务、实现鸿蒙端邮件与日程的高效分发及 SOAP 协议连接方案
flutter·harmonyos·鸿蒙·openharmony
亚历克斯神3 小时前
Flutter 三方库 jwt_io 的鸿蒙化适配指南 - 在鸿蒙系统上构建极致、严谨、全能的 JSON Web Token (JWT) 加解密与身份安全验证引擎
flutter·json·harmonyos
键盘鼓手苏苏3 小时前
Flutter for OpenHarmony:使用 typed_data 直击高性能底层数据操作核心
android·flutter·华为·自动化·harmonyos
加农炮手Jinx3 小时前
Flutter 组件 sse_stream 的适配 鸿蒙Harmony 深度进阶 - 驾驭高并发 Server-Sent Events 背压处理、实现鸿蒙端工业级 AI 响应流与长效链路治理方案
flutter·harmonyos·鸿蒙·openharmony·sse_stream
钛态3 小时前
Flutter 三方库 tftp 的鸿蒙化适配指南 - 实现 RFC 1350 标准的极简文件传输协议、支持端侧嵌入式设备固件更新与局域网数据交换实战
flutter·harmonyos·鸿蒙·openharmony
左手厨刀右手茼蒿3 小时前
Flutter for OpenHarmony:mailer — 基于 SMTP 的极速邮件投递服务(适配鸿蒙 HarmonyOS Next ohos)
android·flutter·华为·交互·harmonyos
雷帝木木3 小时前
Flutter 组件 metalink 的适配 鸿蒙Harmony 深度进阶 - 驾驭节点负载热力均衡、实现鸿蒙端跨域传输安全 (TLS) 与 HAP 原子化精准推送方案
flutter·harmonyos·鸿蒙·openharmony
亚历克斯神3 小时前
Flutter 三方库 eip55 的鸿蒙化适配指南 - 在鸿蒙系统上构建极致、严谨、符合 Web3 标准的以太坊地址校验与防串改引擎
flutter·web3·harmonyos
王码码20353 小时前
Flutter 三方库 soundcloud_explode_dart 的鸿蒙化适配指南 - 实现高性能的 SoundCloud 媒体内容解析、支持音频流下载与全量元数据透传
flutter·harmonyos·鸿蒙·openharmony·soundcloud_explode_dart
国医中兴3 小时前
Flutter 三方库 linalg 的鸿蒙化适配指南 - 掌控高性能线性代数、矩阵运算实战、鸿蒙级算法中枢
线性代数·flutter·harmonyos