Created
June 12, 2013 11:06
-
-
Save kyungw00k/5764413 to your computer and use it in GitHub Desktop.
[Android] Determine which activities can handle the intent
This file contains 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
// 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