Pie*_*rre 33
在华为应用程序库中打开您的应用程序类似于打开 Google Play 商店:
华为应用程序库使用自己的方案appmarket://:
appmarket://com.huawei.appmarket与Google Play 商店对比:
market://com.android.vending以下是华为应用程序库的片段:
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);
}
}
Run Code Online (Sandbox Code Playgroud)
这是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);
}
}
Run Code Online (Sandbox Code Playgroud)
编辑
华为应用程序库现在还支持相同计划的谷歌Play商店:market://com.huawei.appmarket
我同意@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
小智 7
如果您的应用已经在华为应用市场发布,那么您可以使用此url直接打开该应用。
https://appgallery.huawei.com/#/app/C27162
您可以将 appid 替换为您自己的 appid 。
https://appgallery.cloud.huawei.com/appDetail?pkgName=com.huawei.appmarket
您可以将包名称替换为您自己的包名称。
希望它能有所帮助。
小智 -2
好吧兄弟。您可以使用包名称。com.huawei.appmarket 并使用 Intent。这里有一个类似的问题。从 Android 上的另一个应用程序启动一个应用程序
祝你无论做什么都好运
| 归档时间: |
|
| 查看次数: |
8196 次 |
| 最近记录: |