如何在我的Andr​​oid应用程序打开电子邮件附件? [英] How to open email attachment in my app on android?

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

问题描述

我想打开文件的特定类型的我的应用程序已经可以通过发送电子邮件的附件。我需要能有android的电子邮件应用程序选择我的应用程序下载或打开特定文件类型。我不知道如何建立一个意图过滤器,它可以让我做,虽然。任何人都知道如何做到这一点?

I want to open a specific type of file that my app can already send over email as an attachment. I need to be able to have the android email app choose my app to download or open that specific file type. I can't figure out how to set up an intent filter that would let me do that though. Anyone know how this is done?

推荐答案

意图过滤器通常基于MIME类型文件的工作。但是,如果你使用的是自定义的文件格式,Android的不容易识别,那么它不是那么简单。你也许可以尝试使用机器人:pathPattern 属性尝试匹配文件名,但它不是我试过

Intent filters generally work based on MIME type of the file. But if you're using a custom file format that Android's not likely to recognise, then it's not as simple. You can maybe try using the android:pathPattern attribute to try and match the filename, but it's not something I've tried.

我想你会使用这样的事情在你的<活性GT; 标签:

I imagine you'd use something like this in your <activity> tag:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="*/*" />
    <data android:pathPattern=".*\\.xyz" />
</intent-filter>

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

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