Java Code Examples for android.content.Intent#resolveType()

The following examples show how to use android.content.Intent#resolveType() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: medialibrary   File: GalleryUtils.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 2
Source Project: PluginLoader   File: PluginIntentFilter.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * 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());
}
 
Example 3
/**
 * 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());
}