如何从 Android 应用程序发送/打开电子邮件附件? [英] How to send/open email attachments from android app?

查看:45
本文介绍了如何从 Android 应用程序发送/打开电子邮件附件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以某种方式将一个文件从我在一台 Android 设备上的应用程序发送到我在另一台设备上的应用程序.这可以通过任何方式完成,如果你能告诉我如何通过网络发送或类似的东西,我愿意接受建议.

I would like to somehow send a file from my app on one android device to my app on another device. This can be done any which way, and I'm open to suggestions if you can tell me how to send over network or something like that.

目前,我正在考虑将文件作为电子邮件附件发送,但我还没有找到任何关于如何操作的好的文档.我需要两件事来完成此操作,能够将我的文件(存储在 SD 卡上或设备上的某处)作为附件发送,并使我的应用程序被 android 识别为应用程序以打开带有文件扩展名 (.lst) 的附件.

Currently, I'm looking at sending the file as an email attachment, but I haven't found any good documentation on how to do it. I need two things to accomplish this, be able to send my file (stored on sd card or somewhere on device) as an attachment, and have my app recognized by android as the app to open an attachment with the file extention (.lst).

有什么想法吗?

如果这有所不同,这些文件都将是相当小的 xml 文本文件.

The files will all be fairly small xml text files if that makes a difference.

推荐答案

我想以某种方式发送文件从我在一台 android 设备上的应用程序到我在另一台设备上的应用程序.这可以以任何方式完成,我愿意建议,如果你能告诉我如何通过网络发送或类似的东西

I would like to somehow send a file from my app on one android device to my app on another device. This can be done any which way, and I'm open to suggestions if you can tell me how to send over network or something like that.

编写一个 Web 服务.或使用亚马逊 SQS.

Write a Web service. Or use Amazon SQS.

能够发送我的文件(存储在 sd卡或设备上的某个地方)作为附件

be able to send my file (stored on sd card or somewhere on device) as an attachment

正如此处所写,您可以尝试:

As is written up here, you could try:

Intent sendIntent = new Intent(Intent.ACTION_SEND);

sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
sendIntent.putExtra(Intent.EXTRA_STREAM, ...);
sendIntent.setType(...); 

其中第一个省略号是您选择的文件的路径,第二个省略号是合适的 MIME 类型.

where the first ellipsis is the path to your chosen file and the second ellipsis is a suitable MIME type.

并让我的应用程序被 android 识别作为打开附件的应用程序文件扩展名 (.lst)

and have my app recognized by android as the app to open an attachment with the file extention (.lst)

永远不要依赖文件扩展名.使用 MIME 类型.您可以使用 Intent 过滤器设置 Activity,该过滤器为您的 MIME 类型提供 ACTION_VIEW 支持.

Never rely on file extensions. Use MIME types. You can set up an activity with an intent filter that offers ACTION_VIEW support for your MIME type.

这篇关于如何从 Android 应用程序发送/打开电子邮件附件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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