Skip to content

Instantly share code, notes, and snippets.

@kyungw00k
Created June 12, 2013 11:06
Show Gist options
  • Save kyungw00k/5764413 to your computer and use it in GitHub Desktop.
Save kyungw00k/5764413 to your computer and use it in GitHub Desktop.
[Android] Determine which activities can handle the intent
// Determine which activities can handle the intent
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
PackageManager packageManager = getContext().getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
// If there are no relevant activities, don't follow the link
boolean isIntentSafe = activities.size() > 0;
if (!isIntentSafe) {
// Something Wrong
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment