Skip to content

Instantly share code, notes, and snippets.

@GigigoGreenLabs
Last active November 26, 2015 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GigigoGreenLabs/4fdc6e5594285566b295 to your computer and use it in GitHub Desktop.
Save GigigoGreenLabs/4fdc6e5594285566b295 to your computer and use it in GitHub Desktop.
Check if a app is installed and go to the market if not. We have to pass the package of the app in the param.
PackageUtils.startNewActivity(getApplicationContext(), "com.microsoft.office.lync15");
public class PackageUtils {
public static void startNewActivity(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.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment