我使用以下代码打开了Google Play商店
Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setData(Uri.parse("https://play.google.com/store/apps/details?id=my packagename "));
startActivity(i);.
但它向我显示了一个完整的操作视图,用于选择选项(浏览器/播放商店)。我需要直接在Play Store中打开应用程序。
发布于 2019-06-25 14:52:41
作为官方文档使用https://而不是market://,这结合了Eric和M3-N50的答案与代码重用(不要重复自己):
Intent intent = new Intent(Intent.ACTION_VIEW)
.setData(Uri.parse("https://play.google.com/store/apps/details?id=" + getPackageName()));
try {
startActivity(new Intent(intent)
.setPackage("com.android.vending"));
} catch (android.content.ActivityNotFoundException exception) {
startActivity(intent);
}
如果GPlay应用程序存在,它会尝试使用该应用程序打开,并回退到默认设置。
https://stackoverflow.com/questions/11753000
复制相似问题