Example usage for android.webkit MimeTypeMap getMimeTypeFromExtension

List of usage examples for android.webkit MimeTypeMap getMimeTypeFromExtension

Introduction

In this page you can find the example usage for android.webkit MimeTypeMap getMimeTypeFromExtension.

Prototype

@Nullable
public String getMimeTypeFromExtension(String extension) 

Source Link

Document

Return the MIME type for the given extension.

Usage

From source file:Main.java

public static String getMimeType(String extension) {
    String type = null;//from   w  w  w. j  a v  a2  s .c  o  m
    if (extension != null) {
        MimeTypeMap mime = MimeTypeMap.getSingleton();
        type = mime.getMimeTypeFromExtension(extension);
    }
    return type;
}

From source file:Main.java

public static String getMimeType() {
    String type = null;// w w w.j a  va 2  s. c  om
    String extension = "jpg";
    if (extension != null) {
        MimeTypeMap mime = MimeTypeMap.getSingleton();
        type = mime.getMimeTypeFromExtension(extension);
    }
    return type;
}

From source file:Main.java

public static String getMimeType(String uri) {
    String type = null;//ww  w.ja v  a  2 s  .com
    String extension = MimeTypeMap.getFileExtensionFromUrl(uri);
    if (extension != null) {
        MimeTypeMap mime = MimeTypeMap.getSingleton();
        type = mime.getMimeTypeFromExtension(extension);
    }
    return type;
}

From source file:Main.java

public static String getMimeType(String url) {
    String type = null;//from  ww w.  j a  va2  s  . com
    String extension = MimeTypeMap.getFileExtensionFromUrl(url);
    if (extension != null) {
        MimeTypeMap mime = MimeTypeMap.getSingleton();
        type = mime.getMimeTypeFromExtension(extension);
    }
    return type;
}

From source file:Main.java

private static String getMimeTypeForExtension(String ext) {
    MimeTypeMap map = MimeTypeMap.getSingleton();
    return map.getMimeTypeFromExtension(ext);
}

From source file:Main.java

/**
 * Tries to retrieve mime types from file extension
 * @param url/*  www  .j  a  va 2s.  c  o  m*/
 * @return
 */
public static String getMimeType(String url) {
    String type = null;
    String extension = MimeTypeMap.getFileExtensionFromUrl(url);
    if (extension != null) {
        MimeTypeMap mime = MimeTypeMap.getSingleton();
        type = mime.getMimeTypeFromExtension(extension);
    }
    return type;
}

From source file:Main.java

public static String getMimeType(String filePath) {
    if (TextUtils.isEmpty(filePath)) {
        return "";
    }// w ww.  j av  a 2  s .  co  m
    String type = null;
    String extension = getExtensionName(filePath.toLowerCase());
    if (!TextUtils.isEmpty(extension)) {
        MimeTypeMap mime = MimeTypeMap.getSingleton();
        type = mime.getMimeTypeFromExtension(extension);
    }
    Log.i(TAG, "url:" + filePath + " " + "type:" + type);

    // FIXME
    if (TextUtils.isEmpty(type) && filePath.endsWith("aac")) {
        type = "audio/aac";
    }

    return type;
}

From source file:Main.java

/**
 * Returns the MIME type of a document, from its URL.
 *
 * @param url the document url//from w ww  .j  a  v a  2  s.  co m
 * @return the document MIME type
 */
public static String getMimeType(String url) {
    String type = null;
    String extension = MimeTypeMap.getFileExtensionFromUrl(url);
    if (extension != null) {
        MimeTypeMap mime = MimeTypeMap.getSingleton();
        type = mime.getMimeTypeFromExtension(extension);
    }
    if (null == type) {
        type = "application/octet-stream";
    }
    return type;
}

From source file:Main.java

/**
 * To add hack to .3gp file/*from   w ww  . ja v a  2 s.  c  om*/
 * @param url
 * @return
 */
public static String getAudioMimeType(String url) {
    String type = null;
    String extension = MimeTypeMap.getFileExtensionFromUrl(url);
    Log.w("KKIM", " Sending File Extension = " + extension);
    if (extension != null) {
        if (extension.equalsIgnoreCase("3gp") || extension.equalsIgnoreCase("3gpp")) {
            if (is3gpFileAudio(url)) {
                type = "audio/3gpp";
            } else {
                MimeTypeMap mime = MimeTypeMap.getSingleton();
                type = mime.getMimeTypeFromExtension(extension);
            }
        } else {
            MimeTypeMap mime = MimeTypeMap.getSingleton();
            type = mime.getMimeTypeFromExtension(extension);
        }

        if (type.equalsIgnoreCase("application/ogg")) {
            type = "audio/ogg";
            Log.d("KKIM", "Formatting Audio File Type from application/ogg to audio/ogg");
        }
    }
    return type;
}

From source file:com.proofhq.Open.java

/**
 * Returns the MIME type of the file./*from w w  w.  j a v  a2  s  . co  m*/
 *
 * @param path
 * @return
 */
private static String getMimeType(String path) {
    String mimeType = null;

    String extension = MimeTypeMap.getFileExtensionFromUrl(path);
    if (extension != null) {
        MimeTypeMap mime = MimeTypeMap.getSingleton();
        mimeType = mime.getMimeTypeFromExtension(extension);
    }

    System.out.println("Mime type: " + mimeType);

    return mimeType;
}