I get different results when i used GET_INTENT_FILTERS and MATCH_DEFAULT_ONLY when i query the packageManager. Im trying to find the correct filter i need to set. Can somebody explain the difference?
final PackageManager mgr = mContext.getPackageManager();
List<ResolveInfo> list = mgr.queryIntentActivities(intent,
PackageManager.GET_INTENT_FILTERS);
If you specify
MATCH_DEFAULT_ONLYthe call will return aResolveInfoobject for all activities that match the providedIntent. When performing the matching, Android will only consider activities that haveCATEGORY=DEFAULTin their<intent-filter>definition in the manifest. This is the same matching behaviour as used when callingstartActivity()on theIntent. If you do not specify this flag, the query will return all matching activities, even ones that do not containCATEGORY=DEFAULTin their<intent-filter>. Of course, if theIntentthat you pass toqueryIntentActivities()already containsCATEGORY=DEFAULT, then the flag is not needed.If you specify
GET_INTENT_FILTERS, the resultingResolveInfoobjects will also contain theIntentFilterthat was successfully matched. You can access this viaResolveInfo.filter.These 2 flags are not mutually exclusive.
MATCH_DEFAULT_ONLYcontrols how the matching is performed to determine whichResolveInfoobjects to return.GET_INTENT_FILTERScontrols what (additional) information is returned in theResolveInfoobjects themselves. If you want you can specify both flags like thisMATCH_DEFAULT_ONLY | GET_INTENT_FILTERS