在Gmail应用程序忽略自定义MIME类型 [英] Custom mime type ignored in GMail app

查看:177
本文介绍了在Gmail应用程序忽略自定义MIME类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图发送一个文件在Android中使用的意图。我火了意向选择器,选择Gmail应用。问题是,我不能把我的自定义MIME类型,它始终成为应用程序/八位字节流。

I'm trying to send a file in android using intents. I fire up an intent chooser and select the GMail app. The problem is that I can't set my custom mime type, it always becomes application/octet-stream.

在旧版本的Gmail应用程序的它工作得很好做这样的(或者旧版本的Andr​​oid,像pre-JB):

In older versions of the GMail app (or maybe older versions of Android, like pre-JB?) it worked fine doing like this:

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的?

Anyone know how to set the mime type to work with later versions of GMail/Android?

SOM反复试验后,我已看到,在Gmail应用程序版本4这个工作得很好,但在GMail的4.2版本这是不可能的设置MIME类型,或者它以另一种方式完成的。任何人都知道怎么样? :/

After som trial and error have I seen that in GMail app version 4 this works just fine, but in GMail version 4.2 it's not possible to set mime type or it's done in another way. Anyone knows how? :/

推荐答案

不幸的是,没有什么可以做的。有些电子邮件应用,因为神知道什么原因,设置不正确的MIME类型自定义文件,以八位字节流。
你最好的拍摄是设置自定义MIME类型,但随后,在接收端,请确保您也接受八位字节流。然后,您将需要检查的文件扩展名,以确保它确实是你的文件,而不是别的东西,不适合你的应用程序(我假设你使用了自定义的扩展)。

Unfortunately, there is not much you can do. Some email apps, for god knows what reason, incorrectly set the mime type for custom files, to octet-stream. Your best shot is to set your custom mime type, but then, on the receiving end, make sure you also accept octet-stream. Then, you will need to check the file extension to make sure it is indeed your file, and not something else, not intended for your app (I am assuming you are also using a custom extension).

这篇关于在Gmail应用程序忽略自定义MIME类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆