我知道可以在 Google Play 商店中打开我的应用程序(基于包名称),但是如何在华为应用市场中打开我的应用程序?
在华为应用程序库中打开您的应用程序类似于打开 Google Play 商店:
华为应用程序库:
market://
或 appmarket://
com.huawei.appmarket
与。 Google Play 商店:
market://
com.android.vending
这是华为应用程序库的片段:
private void startHuaweiAppGallery() {
Uri detailsUri = Uri.parse("market://details?id=" + getPackageName());
Intent intent = new Intent(Intent.ACTION_VIEW, detailsUri);
List<ResolveInfo> otherApps =
getPackageManager().queryIntentActivities(intent, 0);
for (ResolveInfo app : otherApps) {
String packageName = app.activityInfo.applicationInfo.packageName;
if (!packageName.equals("com.huawei.appmarket")) {
continue;
}
intent.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED |
Intent.FLAG_ACTIVITY_CLEAR_TOP
);
intent.setComponent(new ComponentName(packageName, app.activityInfo.name));
startActivity(intent);
return;
}
//Huawei App Gallery N/A. Open app link in browser.
//Huawei App ID can be found in the Huawei developer console
String huaweiAppID = "100864605";
//ex. https://appgallery.huawei.com/app/C100864605
Uri appUri = Uri.parse(
"https://appgallery.huawei.com/app/C" + huaweiAppID
);
intent = new Intent(Intent.ACTION_VIEW, appUri);
startActivity(intent);
}
这是 Google Play 的片段:
private void startGooglePlay() {
Uri detailsUri = Uri.parse("market://details?id=" + getPackageName());
Intent intent = new Intent(Intent.ACTION_VIEW, detailsUri);
List<ResolveInfo> otherApps =
getPackageManager().queryIntentActivities(intent, 0);
for (ResolveInfo app : otherApps) {
String packageName = app.activityInfo.applicationInfo.packageName;
if (!packageName.equals("com.android.vending")) {
continue;
}
intent.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED |
Intent.FLAG_ACTIVITY_CLEAR_TOP
);
intent.setComponent(new ComponentName(packageName, app.activityInfo.name));
startActivity(intent);
return;
}
//Google Play N/A. Open app link in browser.
Uri appUri = Uri.parse(
"https://play.google.com/store/apps/details?id=" + getPackageName()
);
intent = new Intent(Intent.ACTION_VIEW, appUri);
startActivity(intent);
}
这是允许用户选择设备上的任何可用商店的代码片段:
private void startAnyStore() {
Uri detailsUri = Uri.parse("market://details?id=" + getPackageName());
Intent intent = new Intent(Intent.ACTION_VIEW, detailsUri);
intent.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED |
Intent.FLAG_ACTIVITY_CLEAR_TOP
);
startActivity(intent);
}
我同意@Pierre
但我也认为你可以通过链接解决活动
https://appgallery8.huawei.com/#/app/C<HUAWEI_APP_ID>
或
https://appgallery.cloud.huawei.com/uowap/index.html#/detailApp/C<HUAWEI_APP_ID>?appId=C<HUAWEI_APP_ID>
例如:https://appgallery.cloud.huawei.com/uowap/index.html#/detailApp/C101652909?appId=C101652909
如果您的应用已经在华为应用市场发布,那么您可以使用此url直接打开该应用。
https://appgallery.huawei.com/#/app/C27162
您可以将appid替换为您自己的appid。
https://appgallery.cloud.huawei.com/appDetail?pkgName=com.huawei.appmarket
您可以将包名称替换为您自己的包名称。
希望对您有帮助。
在华为应用市场打开应用程序的简单方法:
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");
华为应用程序库现在似乎可以使用与 Google Play 相同的 URI 打开详细信息页面:
market://details?id=<applicationId>
我刚刚在 AppGallery v11.1.2.304 上尝试了它,并使用两个商店都存在的 applicationId:
adb shell am start -a "android.intent.action.VIEW" -d "market://details?id=busu.blackscreenbatterysaver"
您可以使用华为应用市场提供的徽章服务来推广您的应用,包括准备制作徽章的材料、配置应用链接、获取Referer统计等。通过该服务,您可以高效统计AppGallery中的应用下载量,并为用户提供静默安装服务,提高推广效果。
当用户在频道中点击您的徽章时,用户将被重定向到 AppGallery 上的应用详细信息页面。用户可以点击安装自动下载并安装您的应用程序。
通过包名称启动 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());
}
}
}
以下是直接启动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);
我认为最短、最简单的方法是运行这个简单的链接:
https://appgallery.cloud.huawei.com/ag/n/app/<YOUR_APP_ID>
。
无需配置任何内容,其余的由华为自动处理。
如何获取YOUR_APP_ID?
C5683
好的兄弟。您可以使用包名称。 com.huawei.appmarket 并使用 Intent。这里有一个类似的问题。 从 Android 上的另一个应用程序启动应用程序
祝你无论做什么都好运😊