我正在开发一款Android应用程序,该应用程序允许用户通过Gmail共享其内容。我使用的是Android 2.2版(Froyo)。 问题是我找不到任何工作解决方案,我尝试了几乎所有的东西,但没有运气。 这是我使用的代码:Android:通过Gmail共享zip文件
Intent sharingIntent = new Intent(Intent.ACTION_SEND);;
sharingIntent.setType("application/zip");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
getString(R.string.share_subject));
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, getString(R.string.share_body));
String zipFile = FileProvider.URI_AUTHORITY + File.separator + mItemSelected.getLibraryName() + File.separator + mItemSelected.getZipFileName();
sharingIntent.putExtra(Intent.EXTRA_STREAM, android.net.Uri.parse(zipFile));
startActivity(Intent.createChooser(sharingIntent, (getString(R.string.share_chooser))));
}
在这种情况下的问题是,Gmail应用程序,没有明显的理由,被替换文件的MIME类型,并显示该文件为text/html ,然后我的应用程序不会显示在可以处理这种文件的应用程序列表中。另一个限制是我不想在我的意图过滤器中使用text/html,因为我希望它尽可能地被聚焦,并且如果可能的话,我会定义我自己的MIME类型...
我做了一些研究,发现这question,但没有答案......
更多的MIME类型我想:
application/x-compressed, application/x-zip-compressed
multipart/x-zip and application/octet-stream
是否有此问题的任何解决方案?
谢谢。
这适用于发送KMZ文件。太棒了......但(不幸的是)它提供了很多额外的应用程序,这些应用程序在gmail应用程序旁边并不相关。 – nyaray 2013-08-28 21:11:19
Woop woop,我发现[这个其他答案](http://stackoverflow.com/questions/2197741/how-to-send-email-from-my-android-application),我可以添加'EXTRA_STREAM'到并把它归结为GMail,Google Drive和Skype作为候选应用程序 – nyaray 2013-08-28 21:29:43