【问题标题】:How to open the Huawei AppGallery directly?如何直接打开华为应用市场?
【发布时间】:2019-05-11 08:23:49
【问题描述】:

I know that is possible to open my app (based on package name) in Google PlayStore,但是在华为应用市场怎么做呢?

【问题讨论】:

  • 我认为你不能
  • 不清楚你想从什么打开。你的应用来自画廊,还是来自你的应用的画廊?
  • @VladyslavMatviienko 在华为应用市场打开我的应用。
  • 您必须修改Huawei AppGallery 代码才能打开您的应用程序。只有这样

标签: android google-play huawei-mobile-services huawei-developers


【解决方案1】:

在华为应用程序库中打开您的应用类似于打开 Google Play 商店:

华为应用库使用自己的方案appmarket://

  • 方案: appmarket://
  • 包: com.huawei.appmarket

对比Google Play 商店:

  • 方案: market://
  • 包裹: com.android.vending

这是华为应用程序库的 sn-p:

private void startHuaweiAppGallery() {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("appmarket://details?id=" + getPackageName()));
    List<ResolveInfo> otherApps = getPackageManager().queryIntentActivities(intent, 0);

    boolean agFound = false;

    for (ResolveInfo app : otherApps) {
        if (app.activityInfo.applicationInfo.packageName.equals("com.huawei.appmarket")) {
            ComponentName psComponent = new ComponentName(app.activityInfo.applicationInfo.packageName, app.activityInfo.name);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.setComponent(psComponent);
            startActivity(intent);

            agFound = true;
            break;
        }
    }

    //Optional, Or copy the Google Play Store URL here (See below)
    if (!agFound) {
        //Your Huawei app ID can be found in the Huawei developer console
        final string HUAWEI_APP_ID = "100864605";

        //ex. https://appgallery.cloud.huawei.com/marketshare/app/C100864605
        intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://appgallery.cloud.huawei.com/marketshare/app/C" + HUAWEI_APP_ID));
        startActivity(intent);
    }
}

这是 Google Play 的 sn-p:

private void startGooglePlay() {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName()));
    List<ResolveInfo> otherApps = getPackageManager().queryIntentActivities(intent, 0);

    boolean psFound = false;

    for (ResolveInfo app : otherApps) {
        if (app.activityInfo.applicationInfo.packageName.equals("com.android.vending")) {
            ComponentName psComponent = new ComponentName(app.activityInfo.applicationInfo.packageName, app.activityInfo.name);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.setComponent(psComponent);
            startActivity(intent);

            psFound = true;
            break;
        }
    }
    if (!psFound) {
        intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + getPackageName()));
        startActivity(intent);
    }
}

编辑

Huawei App Gallery 现在也支持与 Google Play Store 相同的Schememarket://com.huawei.appmarket

【讨论】:

    【解决方案2】:

    我同意@Pierre

    但我也认为您可以通过链接解决活动

    https://appgallery8.huawei.com/#/app/C&lt;HUAWEI_APP_ID&gt;

    https://appgallery.cloud.huawei.com/uowap/index.html#/detailApp/C&lt;HUAWEI_APP_ID&gt;?appId=C&lt;HUAWEI_APP_ID&gt;

    例如,https://appgallery.cloud.huawei.com/uowap/index.html#/detailApp/C101652909?appId=C101652909

    【讨论】:

    • 注意C前面的HUAWEI_APP_ID
    【解决方案3】:

    如果您的应用已经在华为应用市场上发布,那么您可以使用该网址直接打开应用。

    1. 你的applcation的appid的URL,例如AppGallery的appid是27162,那么就可以用这个URL打开它

    https://appgallery.huawei.com/#/app/C27162

    你可以用自己的appid替换appid。

    1. 你的应用包名的URL,比如AppGallery的包名是com.huawei.appmarket,那么就可以用这个URL打开它

    https://appgallery.cloud.huawei.com/appDetail?pkgName=com.huawei.appmarket

    您可以将包名替换为您自己的包名。

    希望对您有所帮助。

    【讨论】:

      【解决方案4】:

      在华为应用商店打开应用的简单方法:

      public void reviewApp(String packageName){
              try {
                  Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("appmarket://details?id=" + packageName));
                  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  startActivity(intent);
              } catch (ActivityNotFoundException anfe) {
                  Toast.makeText(this, "Huawei AppGallery not found!", Toast.LENGTH_SHORT).show();
              }
      }
      

      然后从您的活动中调用它:

      reviewApp(this.getPackageName());
      

      或:

      reviewApp("com.myapp.android");
      

      【讨论】:

        【解决方案5】:

        现在华为应用程序库似乎可以使用适用于 Google Play 的相同 URI 打开详细信息页面:market://details?id=&lt;applicationId&gt;

        我刚刚在 AppGallery v11.1.2.304 上试用了一个 applicationId,这两个商店都存在: adb shell am start -a "android.intent.action.VIEW" -d "market://details?id=busu.blackscreenbatterysaver"

        【讨论】:

        • 这可行,但在我的设备上也安装了 APKPure 作为第三方市场。使用此解决方案,它将显示一个对话框来决定应使用哪个商店应用程序来处理意图。此外,部分华为设备还安装了 Google Play Store 和 Huawei App Gallery,这也可能触发此对话框。在我们的用例中,这不是我们想要的行为。
        • 那么你想要的行为是什么?
        • 在我们的例子中,我们希望华为应用程序库自动打开,而无需询问用户他喜欢的商店应用程序。常见用例是要求应用评分/反馈、应用更新或下载另一个应用。在所有情况下,我们都不希望用户选择 APKPure。直接链接到另一个应用程序通常通过应用程序链接而不是普通的深层链接工作。方案 market:// 似乎就像一个普通的深层链接一样工作。
        • 然后,如果您希望完全跳过消歧对话框,唯一的方法是使用带有 appmarket:// 架构的深层链接,正如 Pierre 在接受的答案中指出的那样。对我来说,AppGallery https 链接的行为不像应用程序链接 = 我仍然得到消歧对话框(确实,从应用程序列表中选择华为浏览器来处理意图,它最终会在设备上启动 AppGallery 原生应用程序使用您的应用程序的详细信息)-尝试` adb shell am start -a "android.intent.action.VIEW" -d "appgallery.huawei.com/#/app/C103639735"`。
        • 我提到了使用 market:// 架构的通用解决方案(而不是每个商店使用不同的深层链接),因为当您编写一个希望与平台无关的应用程序时,这会更方便。
        【解决方案6】:

        通过包名启动 Play Store/AppGallery。

        private boolean openInStore(String uri){
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                try {
                    startActivity(Intent.createChooser(intent,getString(R.string.open_with)));
                    return true;
                } catch (ActivityNotFoundException anfe) {
                    return false;
                }
            }
        
            private void startOpenInStore() {
                String playStoreScheme = "market://details?id=", huaweiScheme = "appmarket://details?id=";
                if (!openInStore(playStoreScheme+getPackageName())) {
                    if (!openInStore(huaweiScheme + getPackageName())) {
                        openInStore("https://play.google.com/store/apps/details?id=" + getPackageName());
                    }
                }
            }
        

        【讨论】:

          【解决方案7】:

          您可以使用the badge service provided by HUAWEI AppGallery来推广您的应用程序,包括准备制作徽章的材料、配置应用程序链接以及获取推荐人统计信息。通过该服务,您可以高效地统计AppGallery中的应用下载量,并为用户提供静默安装服务,提高推广效果。

          当用户在频道中点击您的徽章时,用户将被重定向到您在 AppGallery 上的应用详情页面。用户可以点按安装以自动下载并安装您的应用。

          • 制作徽章
          1. 登录AppGallery Connect并点击应用内分发
          2. 点击制作徽章标签。
          3. 点击添加并通过关键字或应用 ID 搜索来添加应用。 (您只能为已发布的应用制作徽章。)
          4. 设置徽章类型中显示徽章、频道名称推荐人。推荐人是可选的。如果需要归因统计,则需要设置参数。
          5. 点击生成徽章以获取徽章及其链接。

          查看下面的截图:

          【讨论】:

            【解决方案8】:

            至于如何链接到AppGallery上的应用详情页面或应用列表页面:

            • 您引用的链接:here 指向应用详细信息页面。华为确实支持使用 AppGallery 上的徽章服务的应用详情页面。也就是说,您可以将 Google 链接替换为华为徽章链接。您可以在here获取徽章服务的详细信息

            • 对于AppGallery上的应用列表,除部分受邀开发者外,华为尚未向所有开发者开放。

            希望对您有所帮助,如有任何问题,请告诉我。

            【讨论】:

              【解决方案9】:

              以下是直接启动 App Gallery 的方法:

              Intent intent = new Intent(Intent.ACTION_VIEW);
              Uri.Builder uriBuilder = Uri.parse("https://appgallery.cloud.huawei.com/ag").buildUpon();
              intent.setData(uriBuilder.build());
              intent.setPackage("com.huawei.appmarket");
              intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              context.startActivity(intent);
              

              【讨论】:

                【解决方案10】:

                我认为最短和最简单的方法是运行这个简单的链接:https://appgallery.cloud.huawei.com/ag/n/app/&lt;YOUR_APP_ID&gt;

                无需任何配置,其余由华为自动处理。

                如何获得 YOUR_APP_ID?

                1. 转到Huawei App Gallery
                2. 搜索您的应用(例如WeChat
                3. 复制链接末尾的ID(例如https://appgallery.huawei.com/#/app/C5683
                4. 在这种情况下,微信的 APP_ID 为C5683
                5. 所以微信的​​华为应用链接是https://appgallery.cloud.huawei.com/ag/n/app/C5683

                【讨论】:

                  【解决方案11】:

                  好的,兄弟。您可以使用包名称。 com.huawei.appmarket 并使用 Intent。这里有一个类似的问题。 Launch an application from another application on Android

                  祝你一切顺利?

                  【讨论】:

                    猜你喜欢
                    • 1970-01-01
                    • 1970-01-01
                    • 2021-09-23
                    • 2020-04-08
                    • 2021-10-10
                    • 1970-01-01
                    • 2014-01-05
                    • 1970-01-01
                    • 1970-01-01
                    相关资源
                    最近更新 更多