在Gmail应用程序忽略自定义MIME类型

编程入门 行业动态 更新时间:2024-10-26 09:35:05
本文介绍了在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类型

本文发布于:2023-07-23 19:28:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1199663.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   应用程序   类型   Gmail   MIME

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!