Skip to content

Instantly share code, notes, and snippets.

@neilbantoc
Last active August 29, 2015 14:00
Show Gist options
  • Save neilbantoc/07fc718c6506126f4a18 to your computer and use it in GitHub Desktop.
Save neilbantoc/07fc718c6506126f4a18 to your computer and use it in GitHub Desktop.
Open or install an app
public static void openOrInstallApp(Context context, String packageName) {
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
if (intent == null) {
intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=" + packageName));
// intent.setData(Uri.parse("http://play.google.com/store/apps/details?id=" + packageName));
}
context.startActivity(intent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment