如何从 Android 应用程序发送/打开电子邮件附件?

发布于 2024-08-17 04:11:51 字数 296 浏览 3 评论 0原文

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

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

有什么想法吗?

如果有区别的话,这些文件都将是相当小的 xml 文本文件。

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.

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).

Any thoughts?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏了南城 2024-08-24 04:11:51

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

编写一个 Web 服务。或者使用 Amazon SQS。

能够发送我的文件(存储在 SD 上)
卡或设备上的某处)作为
附件

此处所写,您可以尝试

Intent sendIntent = new Intent(Intent.ACTION_SEND);

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

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

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

切勿依赖文件扩展名。使用 MIME 类型。您可以使用 Intent 过滤器设置 Activity,为您的 MIME 类型提供 ACTION_VIEW 支持。

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.

Write a Web service. Or use Amazon SQS.

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(...); 

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

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

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.

羁客 2024-08-24 04:11:51

我这样做是为了处理附加到邮件的 vcf 文件,它有效。以下是意图文件管理器:

        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="android.intent.action.VIEW" />
            <data android:mimeType="text/x-vcard" />
        </intent-filter>

请参阅 http://code.google.com/p 中的完整代码/卡片捕手

I did this in order to process vcf files attached to mails and it worked. Here is the intent filer:

        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="android.intent.action.VIEW" />
            <data android:mimeType="text/x-vcard" />
        </intent-filter>

See the whole code in http://code.google.com/p/card-catcher.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文