19

I know that is possible to open my app (based on package name) in Google Play Store, but how to do same in Huawei AppGallery?

Zinna
  • 1,591
  • 2
  • 2
  • 15
Michalsx
  • 2,515
  • 3
  • 23
  • 39

10 Answers10

29

Opening your app in the Huawei App Gallery is similar to opening Google Play Store:

Huawei App Gallery uses its own scheme appmarket://:

  • Scheme: appmarket://
  • Package: com.huawei.appmarket

vs. Google Play Store:

  • Scheme: market://
  • Package: com.android.vending

Here is a snippet for the Huawei App Gallery:

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);
    }
}

Here is the snippet for Google Play:

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);
    }
}
Pierre
  • 6,347
  • 4
  • 48
  • 67
8

I agree with @Pierre

But I also think you can resolve activity with links

https://appgallery8.huawei.com/#/app/C<HUAWEI_APP_ID>

or

https://appgallery.cloud.huawei.com/uowap/index.html#/detailApp/C<HUAWEI_APP_ID>?appId=C<HUAWEI_APP_ID>

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

2

A simple way to open app in Huawei App Gallery store:

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();
        }
}

then call it from your activity:

reviewApp(this.getPackageName());

or:

reviewApp("com.myapp.android");
essayoub
  • 615
  • 1
  • 6
  • 14
1

Launch Play Store/AppGallery via package name.

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());
            }
        }
    }
1

If your application has already released on the Huawei Appgallery, then you can use this url to open the application directly.

  1. URL with the appid of your applcation, for example the AppGallery's appid is 27162, then can open it with this URL

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

You can replace the appid with your own appid .

  1. URL with the package name of your application, for example the AppGallery's package name is com.huawei.appmarket, then can open it with this URL

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

You can replace the package name with your own package name.

Wish it can be helpful.

Jeffrey
  • 31
  • 2
1

It seems Huawei App Gallery can now open the details page with the same URI that works for Google Play: market://details?id=<applicationId>

I just tried it out on AppGallery v11.1.2.304 with an applicationId that exists on both stores: adb shell am start -a "android.intent.action.VIEW" -d "market://details?id=busu.blackscreenbatterysaver"

Adi B
  • 581
  • 3
  • 10
  • This works, but on my device is also APKPure as third party market installed. With this solution it will show a dialog to decide which store app should be used to handle the intent. Also some huawei devices still have Google Play Store and Huawei App Gallery installed, which might also trigger this dialog. In our use case this is not the desired behavior. – lilienberg Apr 20 '21 at 09:39
  • so what's your desired behavior? – Adi B Apr 20 '21 at 12:14
  • In our case we want the Huawei App Gallery to open automatically without asking the user for his preferred store app. Common use cases are either asking for app rating/feedback, app update or downloading another app. In all cases we do not want that the user picks the APKPure. Direct linking to another app works normally via app links instead of plain deep links. The scheme market:// seems to works just as a normal deep link. – lilienberg Apr 22 '21 at 06:06
  • Then if you wish to skip the disambiguation dialog altogether, the only way is using a deep link with the `appmarket://` schema as Pierre indicated in the accepted answer. For me, the AppGallery https links didn't behave like app links = I still got the disambiguation dialog (it's true that selecting the Huawei Browser from the list of apps to handle the intent, it will eventually launch the AppGallery native app on the device with your app's details) - try ` adb shell am start -a "android.intent.action.VIEW" -d "https://appgallery.huawei.com/#/app/C103639735"`. – Adi B May 12 '21 at 10:34
  • I mentioned the universal solution using the `market://` schema (instead of different deep links per store) because that's more convenient when you code an app you wish to be platform agnostic. – Adi B May 12 '21 at 10:34
0

You can use the badge service provided by HUAWEI AppGallery to promote your app, including preparing materials for making a badge, configuring an app link, and obtaining referrer statistics. With the service, you can efficiently collect statistics on app downloads in AppGallery and provide the silent installation service for users to improve the promotion effect.

When a user taps your badge in a channel, the user is redirected to your app details page on AppGallery. The user can tap Install to automatically download and install your app.

  • Making a badge
  1. Sign in to AppGallery Connect and click In-app distribution.
  2. Click the Make badge tab.
  3. Click Add and add an app either by searching by keyword or app ID. (You can only make a badge for a released app.)
  4. Set Badge type, Display badge in, Channel name, and Referrer. The referrer is optional. If attribution statistics is required, you need to set the parameter.
  5. Click Generate badge to obtain the badge and its link.

Check the screenshot below: badge service

shirley
  • 6,207
  • 1
  • 14
  • 32
0

As for how to link to an app detail page or an app list page on AppGallery:

• The link that you referred: here is to an app detail page. Huawei does support the app detail page using badge service on AppGallery. In other words, you can replace the Google link with Huawei badge link. You can get the detail information of badge service at here

• For app listing on AppGallery, Huawei has not opened the ability to all developers except some invited developers.

Hope this help and let me know if any questions.

Zinna
  • 1,591
  • 2
  • 2
  • 15
0

Here is how to start App Gallery directly:

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);
-2

Ok bro. You can use the package name. com.huawei.appmarket and use Intent. There is a similar question here. Launch an application from another application on Android

Good luck for whatever you doing

MmxKnows
  • 7
  • 1