Java Code Examples for android.webkit.MimeTypeMap#hasExtension()

The following examples show how to use android.webkit.MimeTypeMap#hasExtension() . 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: a   File: FileUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 获取文件的MIME类型
 */
public static String getMimeType(String pathOrUrl) {
    String ext = getExtension(pathOrUrl);
    MimeTypeMap map = MimeTypeMap.getSingleton();
    String mimeType;
    if (map.hasExtension(ext)) {
        mimeType = map.getMimeTypeFromExtension(ext);
    } else {
        mimeType = "*/*";
    }
    return mimeType;
}
 
Example 2
Source Project: FilePicker   File: FileUtils.java    License: MIT License 5 votes vote down vote up
/**
 * 获取文件的MIME类型
 */
public static String getMimeType(String pathOrUrl) {
    String ext = getExtension(pathOrUrl);
    MimeTypeMap map = MimeTypeMap.getSingleton();
    String mimeType;
    if (map.hasExtension(ext)) {
        mimeType = map.getMimeTypeFromExtension(ext);
    } else {
        mimeType = "*/*";
    }
    return mimeType;
}
 
Example 3
/**
 * 获取文件的MIME类型
 */
public static String getMimeType(String pathOrUrl) {
    String ext = getExtension(pathOrUrl);
    MimeTypeMap map = MimeTypeMap.getSingleton();
    String mimeType;
    if (map.hasExtension(ext)) {
        mimeType = map.getMimeTypeFromExtension(ext);
    } else {
        mimeType = "*/*";
    }
    return mimeType;
}
 
Example 4
Source Project: AndroidDownload   File: FileUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取文件的MIME类型
 */
public static String getMimeType(String pathOrUrl) {
    String ext = getExtension(pathOrUrl);
    MimeTypeMap map = MimeTypeMap.getSingleton();
    String mimeType;
    if (map.hasExtension(ext)) {
        mimeType = map.getMimeTypeFromExtension(ext);
    } else {
        mimeType = "*/*";
    }
    return mimeType;
}
 
Example 5
Source Project: tindroid   File: UiUtils.java    License: Apache License 2.0 5 votes vote down vote up
static String getMimeType(Uri uri) {
    if (uri == null) {
        return null;
    }

    MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
    String ext = MimeTypeMap.getFileExtensionFromUrl(uri.toString());
    if (mimeTypeMap.hasExtension(ext)) {
        return mimeTypeMap.getMimeTypeFromExtension(ext);
    }
    return null;
}
 
Example 6
Source Project: AndroidPicker   File: FileUtils.java    License: MIT License 5 votes vote down vote up
/**
 * 获取文件的MIME类型
 */
public static String getMimeType(String pathOrUrl) {
    String ext = getExtension(pathOrUrl);
    MimeTypeMap map = MimeTypeMap.getSingleton();
    String mimeType;
    if (map.hasExtension(ext)) {
        mimeType = map.getMimeTypeFromExtension(ext);
    } else {
        mimeType = "*/*";
    }
    LogUtils.verbose(pathOrUrl + ": " + mimeType);
    return mimeType;
}