Skip to content

Instantly share code, notes, and snippets.

@alvareztech
Created October 16, 2020 14:03
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 alvareztech/3c6aa3323a164701f911632ea49158ef to your computer and use it in GitHub Desktop.
Save alvareztech/3c6aa3323a164701f911632ea49158ef to your computer and use it in GitHub Desktop.
if (isAppInstalled("com.google.android.apps.maps")) {
// Normal process
} else {
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com/maps/dir/Current+Location/-17.760294,-63.201106"));
startActivity(myIntent);
}
private boolean isAppInstalled(String uri) {
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
return true;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment