diff --git a/.idea/misc.xml b/.idea/misc.xml index 258caf4..342a898 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -84,7 +84,7 @@ - + diff --git a/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/MergeIntent.java b/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/MergeIntent.java index 4316e55..b26e64a 100644 --- a/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/MergeIntent.java +++ b/intentmanip/src/main/java/xyz/belvi/intentmanip/IntentUtils/MergeIntent.java @@ -14,12 +14,13 @@ * Created by zone2 on 10/2/16. */ -public class MergeIntent { +public class MergeIntent extends ManipUtils { public static List mergeIntents(Context context, Intent... intents) { PackageManager packageManager = context.getPackageManager(); + List resolveIntents = new ArrayList<>(); for (Intent intent : intents) { List listCam = packageManager.queryIntentActivities(intent, 0); @@ -29,4 +30,24 @@ public static List mergeIntents(Context context, Intent... intent } return resolveIntents; } + + public static List distinctMerge(Context context, Intent... intents) { + + PackageManager packageManager = context.getPackageManager(); + + + ArrayList intentsNameLog = new ArrayList<>(); + List resolveIntents = new ArrayList<>(); + for (Intent intent : intents) { + List listCam = packageManager.queryIntentActivities(intent, 0); + for (ResolveInfo res : listCam) { + if (!intentsNameLog.contains(getPackageName(res))) { + intentsNameLog.add(getPackageName(res)); + resolveIntents.add(new ResolveIntent(res, intent)); + } + } + } + intentsNameLog.clear(); + return resolveIntents; + } }