Android 打开应用商店评分

最近处理华为渠道包,打开应用商店评分系统,简单整理一下跳转商店的代码,以便将来翻看

国内应用商店跳转

跳转华为应用商店进行评分
先判断设备是否安装应用商店,如果没有安装应用商店,则跳转至对应的网页进行下载
注:appId 是在华为控制台创建应用的id

注:appId 是在华为控制台创建应用的id
public static void openHmsStore ( ) {
	requestHmsStoreReviewLeve("com.huawei.appmarket");
}
    public static void requestHmsStoreReviewLeve(final String marketPkg)
    {
        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    String appPkg = activity.getPackageName();
                    if (TextUtils.isEmpty(appPkg))
                        return;
                    Uri uri = Uri.parse("market://details?id=" + appPkg);
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    if (!TextUtils.isEmpty(marketPkg))
                        intent.setPackage(marketPkg);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

                    if (intent.resolveActivity(activity.getPackageManager()) == null) {
                        uri = Uri.parse("https://appstore.huawei.com/app/C" + appId);
                        intent = new Intent(Intent.ACTION_VIEW, uri);
                    }
                    activity.startActivity(intent);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

常见应用商店marketPkg name参考:https://blog.csdn.net/Mr___Xu/article/details/101220574

谷歌商店跳转

谷歌商店通过url地址进行跳转,如果设备安装商店APP会自动跳转到商店,没有安装商店则跳转到网页

public static void openGooglePlayStore ( ) {
	showGooglePlayStore();
}
    public static void showGooglePlayStore()
    {
        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
            	String appPkg = activity.getPackageName();
            	String url = "http://play.google.com/store/apps/details?id=" + appPkg;
                Log.d(TAG, "rate url :" + url);
                activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
            }
        });
    }
苹果商店跳转
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.3f)
        {
            [SKStoreReviewController requestReview];
            return;
        }
        
        NSString *str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@?action=write-review", appId];    
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天涯过客TYGK

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值