Check if there is an exported activity for the intent

This commit is contained in:
Martin Fietz 2016-06-10 19:57:38 +02:00
parent a7a2043682
commit ce2125e647

View File

@ -9,10 +9,18 @@ import java.util.List;
public class IntentUtils {
/*
* Checks if there is at least one exported activity that can be performed for the intent
*/
public static boolean isCallable(final Context context, final Intent intent) {
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
for(ResolveInfo info : list) {
if(info.activityInfo.exported) {
return true;
}
}
return false;
}
}