电子邮件意图的附加功能 - 首选项 XML
我想从我的 xml 首选项屏幕触发电子邮件,并附加预定义的主题并在电子邮件应用程序的正文字段中启动光标
这是我到目前为止所得到的内容
<Preference
android:title="Support"
android:summary="Having a problem?">
<intent
android:action="android.intent.action.VIEW"
android:data="mailto:[email protected]"
/>
</Preference>
非常适合触发电子邮件意图,但是我将如何通过 xml 完成其他任务?附加主题和所有内容?
I'm wanting to trigger an Email from my xml preferences screen and also attach a pre-defined subject and start the cursor in the Body field of the email application
Here's what I've got so far
<Preference
android:title="Support"
android:summary="Having a problem?">
<intent
android:action="android.intent.action.VIEW"
android:data="mailto:[email protected]"
/>
</Preference>
Works great for triggering the email intent, but how would i go about accomplishing the others via xml? attaching the subject and all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 jondavidjohn 所说,您可以使用 mailto 查询参数,也可以使用意图附加参数,并且您可以混合和匹配它们。例如:
...将允许您设置电子邮件的正文和主题。您还可以指定主题作为额外内容。这也让您可以使用 XML 字符串资源而不是硬编码:
我刚刚从 Intent.java 中获取了 Intent 的额外名称;与电子邮件相关的都集中在一起。
我刚刚发现这一点,还没有进行太多测试,但这似乎确实适用于我的 GMail 邮件客户端。
另外,如果有任何帮助的话,我确实成功地使用了 mailto: URI 的“正文”,例如,
不知道我对 mailto URL 进行 url 编码是否有帮助;我只是出于习惯的力量而这样做,来自网络背景。但这确实有效,并且在 GMail 和 K9 Mail 应用程序中都具有一定的作用。
You can use both mailto query parameters, as jondavidjohn says, and also intent extras, and you can mix and match them both. For example:
...will allow you to set the body of an email as well as the subject. You can also specify the subject as an extra. This lets you use XML string resources rather than hardcoding, too:
I just grabbed the Intent extra names from Intent.java; the email-related ones are all in a bunch together.
I've only just discovered this and haven't done much testing, but this certainly seems to work with my GMail mail client.
Also, if it's any help, I did have success using the "body" of the mailto: URI, e.g.
Don't know whether it helped that I url-encoded my mailto URL; I was just doing it through force of habit, coming from a web background. But that definitely works and sets a body in both GMail and K9 Mail apps.
显然,您可以使用普通浏览器 mailto: uri 上可以使用的许多查询字符串参数。
因此,要实现此目的,您只需像这样使用它们即可。
Apparently you can use many of the querystring arguments that you can on the normal browser mailto: uri.
So to accomplish this you just have to use them like this.