在电子邮件意向额外 - preferences XML [英] Extras on Email Intent - Preferences XML

查看:330
本文介绍了在电子邮件意向额外 - preferences XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的XML preferences屏幕触发电子邮件,并附加一个pre定义主题和启动光标在电子邮件应用程序中的主体领域

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

下面是我有这么远

  <Preference
    android:title="Support"
    android:summary="Having a problem?">

    <intent
      android:action="android.intent.action.VIEW"
      android:data="mailto:support@xxxxx.com"
      />

  </Preference>

伟大的作品用于触发电子邮件的意图,但如何将我去通过XML完成其他人呢?附加的主题和所有?

Works great for triggering the email intent, but how would i go about accomplishing the others via xml? attaching the subject and all?

推荐答案

您可以同时使用邮寄地址的查询参数,jondavidjohn说,还意图演员,你可以混合和匹配他们。例如:

You can use both mailto query parameters, as jondavidjohn says, and also intent extras, and you can mix and match them both. For example:

<intent
  android:action="android.intent.action.VIEW"
  android:data="mailto:xxxxx@xxxxxxx.com?subject=this is a test subject">
  <extra android:name="android.intent.extra.TEXT" android:value="This is a test" />
</intent>

...将允许您设置一个电子邮件的正文以及主题。您也可以指定主题作为一个额外的。这可让您使用XML字符串资源,而不是硬编码,也:

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

  <extra android:name="android.intent.extra.SUBJECT" android:value="@string/email_subject" />

我只是抓住从Intent.java的意向额外的名字;电子邮件相关的人都在一堆在一起。

I just grabbed the Intent extra names from Intent.java; the email-related ones are all in a bunch together.

我刚刚发现这一点,并没有做多少测试,但是这肯定似乎与我的Gmail邮件客户端的工作。

I've only just discovered this and haven't done much testing, but this certainly seems to work with my GMail mail client.

此外,如果它的任何帮助,我也必须使用邮寄地址的身体的成功:URI,例如:

Also, if it's any help, I did have success using the "body" of the mailto: URI, e.g.

 mailto:example@example.com?subject=This%20is%20a%20subject&body=This%20is%20a%20body

不知道它是否帮助了我的URL连接codeD我的mailto URL;我只是做它通过习惯势力,从网页背景的。但是,这肯定工程,并设置一个身在Gmail和K9邮件​​的应用程序。

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.

这篇关于在电子邮件意向额外 - preferences XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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