Skip to content

Instantly share code, notes, and snippets.

@ruan65
Last active September 22, 2016 09:35
Show Gist options
  • Save ruan65/4c1442f38dc28d95ace62e7aa80f1524 to your computer and use it in GitHub Desktop.
Save ruan65/4c1442f38dc28d95ace62e7aa80f1524 to your computer and use it in GitHub Desktop.
Static method to open Play Market by package name
public static void openPlayMarketByPackageName(Context ctx, String packageName) {
try {
ctx.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=" + packageName)));
} catch (android.content.ActivityNotFoundException anfe) {
ctx.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=" + packageName)));
} catch (Exception ex) {
ex.printStackTrace();
// crap.....
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment