You can do this using the market://
prefix .
(您可以使用market://
前缀执行此操作。)
final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
We use a try/catch
block here because an Exception
will be thrown if the Play Store is not installed on the target device.
(我们使用try/catch
这里块,因为Exception
将被抛出,如果Play商店未在目标设备上安装。)
NOTE : any app can register as capable of handling the market://details?id=<appId>
Uri, if you want to specifically target Google Play check the Ber?ák answer
(注意 :任何应用都可以注册为能够处理market://details?id=<appId>
Uri,如果您想专门针对Google Play检查Ber?ák答案)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…