Rajesh Kumar Rajesh Kumar - 11 months ago 144
Android Question

How to open the Google Play Store directly from my Android application?

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

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.


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

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