Last active
September 22, 2016 09:35
-
-
Save ruan65/4c1442f38dc28d95ace62e7aa80f1524 to your computer and use it in GitHub Desktop.
Static method to open Play Market by package name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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