本文整理汇总了Java中android.content.IntentFilter.NO_MATCH_DATA属性的典型用法代码示例。如果您正苦于以下问题:Java IntentFilter.NO_MATCH_DATA属性的具体用法?Java IntentFilter.NO_MATCH_DATA怎么用?Java IntentFilter.NO_MATCH_DATA使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.content.IntentFilter
的用法示例。
在下文中一共展示了IntentFilter.NO_MATCH_DATA属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doMatchIntent
/**
* 根据 Intent 匹配组件
*
* @param context Context
* @param intent 调用方传来的 Intent
* @param filtersMap 插件中声明的所有组件和 IntentFilter
* @return ComponentInfo
*/
public static String doMatchIntent(Context context, Intent intent, Map<String, List<IntentFilter>> filtersMap) {
if (filtersMap == null) {
return null;
}
final String action = intent.getAction();
final String type = intent.resolveTypeIfNeeded(context.getContentResolver());
final Uri data = intent.getData();
final String scheme = intent.getScheme();
final Set<String> categories = intent.getCategories();
for (Map.Entry<String, List<IntentFilter>> entry : filtersMap.entrySet()) {
String pluginName = entry.getKey();
List<IntentFilter> filters = entry.getValue();
if (filters == null) {
continue;
}
for (IntentFilter filter : filters) {
int match = filter.match(action, type, scheme, data, categories, "ComponentList");
if (match >= 0) {
if (LOG) {
LogDebug.d(TAG, "IntentFilter 匹配成功: " + entry.getKey());
}
return pluginName;
} else {
if (LOG) {
String reason;
switch (match) {
case IntentFilter.NO_MATCH_ACTION:
reason = "action";
break;
case IntentFilter.NO_MATCH_CATEGORY:
reason = "category";
break;
case IntentFilter.NO_MATCH_DATA:
reason = "data";
break;
case IntentFilter.NO_MATCH_TYPE:
reason = "type";
break;
default:
reason = "unknown reason";
break;
}
LogDebug.d(TAG, " Filter did not match: " + reason);
}
}
}
}
return "";
}