下面列出了android.content.Intent#resolveType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
public static int determineTypeBits(Context context, Intent intent) {
int typeBits = 0;
String type = intent.resolveType(context);
if (MIME_TYPE_ALL.equals(type)) {
typeBits = DataManager.INCLUDE_ALL;
} else if (MIME_TYPE_IMAGE.equals(type) ||
DIR_TYPE_IMAGE.equals(type)) {
typeBits = DataManager.INCLUDE_IMAGE;
} else if (MIME_TYPE_VIDEO.equals(type) ||
DIR_TYPE_VIDEO.equals(type)) {
typeBits = DataManager.INCLUDE_VIDEO;
} else {
typeBits = DataManager.INCLUDE_ALL;
}
if (ApiHelper.HAS_INTENT_EXTRA_LOCAL_ONLY) {
if (intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false)) {
typeBits |= DataManager.INCLUDE_LOCAL_ONLY;
}
}
return typeBits;
}
/**
* Test whether this filter matches the given <var>intent</var>.
*
* @param intent The Intent to compare against.
* @param resolve If true, the intent's type will be resolved by calling
* Intent.resolveType(); otherwise a simple match against
* Intent.type will be performed.
* @param logTag Tag to use in debugging messages.
*
* @return Returns either a valid match constant (a combination of
* {@link #MATCH_CATEGORY_MASK} and {@link #MATCH_ADJUSTMENT_MASK}),
* or one of the error codes {@link #NO_MATCH_TYPE} if the type didn't match,
* {@link #NO_MATCH_DATA} if the scheme/path didn't match,
* {@link #NO_MATCH_ACTION if the action didn't match, or
* {@link #NO_MATCH_CATEGORY} if one or more categories didn't match.
*
* @return How well the filter matches. Negative if it doesn't match,
* zero or positive positive value if it does with a higher
* value representing a better match.
*
* @see #match(String, String, String, android.net.Uri , Set, String)
*/
public final int match(ContentResolver resolver, Intent intent,
boolean resolve, String logTag) {
String type = resolve ? intent.resolveType(resolver) : intent.getType();
return match(intent.getAction(), type, intent.getScheme(),
intent.getData(), intent.getCategories());
}
/**
* Test whether this filter matches the given <var>intent</var>.
*
* @param intent The Intent to compare against.
* @param resolve If true, the intent's type will be resolved by calling
* Intent.resolveType(); otherwise a simple match against
* Intent.type will be performed.
* @param logTag Tag to use in debugging messages.
*
* @return Returns either a valid match constant (a combination of
* {@link #MATCH_CATEGORY_MASK} and {@link #MATCH_ADJUSTMENT_MASK}),
* or one of the error codes {@link #NO_MATCH_TYPE} if the type didn't match,
* {@link #NO_MATCH_DATA} if the scheme/path didn't match,
* {@link #NO_MATCH_ACTION if the action didn't match, or
* {@link #NO_MATCH_CATEGORY} if one or more categories didn't match.
*
* @return How well the filter matches. Negative if it doesn't match,
* zero or positive positive value if it does with a higher
* value representing a better match.
*
* @see #match(String, String, String, android.net.Uri , Set, String)
*/
public final int match(ContentResolver resolver, Intent intent,
boolean resolve, String logTag) {
String type = resolve ? intent.resolveType(resolver) : intent.getType();
return match(intent.getAction(), type, intent.getScheme(),
intent.getData(), intent.getCategories());
}