如何打开谷歌从我的Andr​​oid应用程序Play商店直接?我的、应用程序、商店、直接

由网友(我的人生就缺你℡)分享简介:我必须使用follwing code。打开谷歌Play商店I have open the google play store using the follwing code Intent i = new Intent(android.content.Intent.ACTION_VIEW);i.setData(Ur...

我必须使用follwing code。打开谷歌Play商店

I have open the google play store using the follwing code

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);.

但它显示了我一个完整的动作查看选择该选项(浏览器/播放存储)。我需要在playstore直接打开应用程序。

But it shows me a Complete Action View as to select the option (browser/play store). I need to open the application in playstore directly.

推荐答案

您可以使用做到这一点的market:// preFIX 。

You can do this using the market:// prefix.

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)));
}

我们用的try / catch 阻塞在这里,因为异常将如果没有安装Play商店甩目标设备

We use a try/catch block here because an Exception will be thrown if the Play Store is not installed on the target device.

阅读全文

相关推荐

最新文章