I know that is possible to open my app (based on package name) in Google Play商店,但如何在华为AppGallery中做同样的事情?
发布于 2019-10-11 22:13:52
在华为应用程序库中打开您的应用程序与打开Google Play Store类似:
华为应用程序库使用自己的方案appmarket://
appmarket://com.huawei.appmarket谷歌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);
}
}这是谷歌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);
}
}编辑
华为应用程序库现在还支持与 Play商店相同的方案:market://com.huawei.appmarket
发布于 2020-06-16 20:46:53
我同意@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
发布于 2020-03-12 01:00:19
在华为app Gallery商店打开App的简单方法:
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");https://stackoverflow.com/questions/53705612
复制相似问题