admin管理员组文章数量:1624784
最近处理华为渠道包,打开应用商店评分系统,简单整理一下跳转商店的代码,以便将来翻看
国内应用商店跳转
跳转华为应用商店进行评分
先判断设备是否安装应用商店,如果没有安装应用商店,则跳转至对应的网页进行下载
注: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/app/C" + appId);
intent = new Intent(Intent.ACTION_VIEW, uri);
}
activity.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
常见应用商店marketPkg name参考:https://blog.csdn/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/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/app/id%@?action=write-review", appId];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
版权声明:本文标题:Android 打开应用商店评分 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1728909012a1179042.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论