【发布时间】:2012-12-01 23:25:15
【问题描述】:
我正在尝试使用意图在 android 中发送文件。我启动了一个意图选择器并选择了 GMail 应用程序。问题是我无法设置我的自定义 mime 类型,它总是变成 application/octet-stream。
在旧版本的 GMail 应用程序中(或者可能是旧版本的 Android,如 JB 之前的版本?)它可以像这样工作:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
// Add attributes to the intent
sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Send my file");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(path));
sendIntent.setType("application/vnd.mycustommimetype");
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.lblShare)));
有人知道如何设置 MIME 类型以与更高版本的 GMail/Android 一起使用吗?
经过反复试验,我发现在 GMail 应用程序版本 4 中这工作得很好,但在 GMail 版本 4.2 中,无法设置 mime 类型或以其他方式完成。有谁知道怎么做? :/
【问题讨论】:
-
我也有同样的问题。你找到解决办法了吗?
-
在 Android 5.0 中仍然存在问题
标签: android gmail mime-types