本文整理匯總了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 "";
}