如何打开谷歌从我的Android应用程序Play商店直接? [英] How to open the Google Play Store directly from my Android application?
本文介绍了如何打开谷歌从我的Android应用程序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(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.
推荐答案
您可以使用做到这一点的<一个href="http://developer.android.com/distribute/googleplay/promote/linking.html"><$c$c>market://$c$c> 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.
这篇关于如何打开谷歌从我的Android应用程序Play商店直接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文