Example usage for android.webkit MimeTypeMap getSingleton

List of usage examples for android.webkit MimeTypeMap getSingleton

Introduction

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

Prototype

public static MimeTypeMap getSingleton() 

Source Link

Document

Get the singleton instance of MimeTypeMap.

Usage

From source file:Main.java

public static String getMineType(String path) {
    String suffix = getSuffix(path);
    return MimeTypeMap.getSingleton().getMimeTypeFromExtension(suffix.toLowerCase());
}

From source file:Main.java

public static String getFileSuffixForImage(@NonNull String mimeType) {
    return MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType);
}

From source file:Main.java

public static String getMimeType(String fileUrl) {
    String extension = MimeTypeMap.getFileExtensionFromUrl(fileUrl);
    return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
}

From source file:Main.java

static boolean isVideo(File file) {

    Uri uri = Uri.fromFile(file);//from   ww  w  . j a  va  2  s .c  o  m
    String type = MimeTypeMap.getSingleton()
            .getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(uri.toString()));

    if (type == null)
        return false;
    else
        return (type.toLowerCase().startsWith("video/"));
}

From source file:Main.java

public static boolean isPicture(File file) {

    Uri uri = Uri.fromFile(file);//from   w ww  .  j  a  v a 2s .  c  o m
    String type = MimeTypeMap.getSingleton()
            .getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(uri.toString()));

    if (type == null)
        return false;
    else
        return (type.toLowerCase().startsWith("image/"));
}

From source file:Main.java

public static String getFileMimeType(File file) {
    String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(getExtension(file));
    if (type == null)
        return "*/*";
    return type;/* w  w  w  .  j a v  a  2s . co  m*/
}

From source file:Main.java

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

From source file:Main.java

public static String getMIMETypeFromUrl(final File file, final String defaultValue) {

    MimeTypeMap mime = MimeTypeMap.getSingleton();
    int index = file.getName().lastIndexOf('.') + 1;
    String ext = file.getName().substring(index).toLowerCase();
    final String mimeType = mime.getMimeTypeFromExtension(ext);

    if (mimeType != null) {
        return mimeType;
    }/* ww  w  .  j  a va 2 s. c  om*/

    return defaultValue;
}

From source file:Main.java

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

From source file:Main.java

public static String getMineType(String url) {
    final String ext = getFileExtensionFromUrl(url);
    return MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext);
}