【问题标题】:MIME type for files文件的 MIME 类型
【发布时间】:2011-03-21 14:40:21
【问题描述】:

我想通过我的应用程序处理一些文件,因为我正在使用以下代码

Intent intent = new Intent(Intent.ACTION_VIEW);
                            intent.setDataAndType(Uri.fromFile(new File(f.getAbsolutePath() + "/" + fileName)), fileType);
                            startActivity(intent);

我想处理一些文件,因为我需要 MIME 类型的以下文件

1)Office 文件(DOC、PPT、XLS、Word 等) 2)VCF 3)AVI、3gp、flv 等 4)APK

如果您知道,请发布任何...

如果有其他方法可以处理文件,请告诉我

谢谢你..:)

【问题讨论】:

    标签: android mime-types


    【解决方案1】:

    我猜你可以使用URLConnection.guessContentTypeFromName(String url) 找出 MIME 类型。我还没有测试过,但我也需要这个,所以我会试一试。

    【讨论】:

      【解决方案2】:

      1) http://fileext.com/faq/office_mime_types.php 用于办公类型。 2) vcf 的“text/x-vcard” 3) http://www.w3schools.com/media/media_mimeref.asp 和http://filext.com 用于电影 4) "application/vnd.android.package-archive" 用于 apk 文件 我使用 filename.endsWith("doc") 来确定文件类型。我知道这不是最优雅的解决方案,但我无法让 URLConnection.guessContentTypeFromName(String url) 为我工作......

      【讨论】:

        猜你喜欢
        • 2018-06-27
        • 2019-01-28
        • 2021-02-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-07
        • 2018-12-01
        • 2020-07-11
        相关资源
        最近更新 更多