我想从我的xml首选项屏幕触发一封电子邮件,同时附加一个预定义的主题,并在电子邮件应用程序的正文字段中启动光标
这是我到目前为止所得到的
<Preference
android:title="Support"
android:summary="Having a problem?">
<intent
android:action="android.intent.action.VIEW"
android:data="mailto:support@xxxxx.com"
/>
</Preference>对于触发电子邮件意图非常有用,但是我如何通过xml来实现其他目的呢?附加主题和所有内容?
发布于 2012-03-12 19:42:18
正如jondavidjohn所说,您既可以使用mailto查询参数,也可以使用intent附加参数,并且可以混合和匹配它们。例如:
<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>...will允许您设置电子邮件的正文和主题。您还可以将主题指定为附加主题。这让您可以使用XML字符串资源,而不是硬编码:
<extra android:name="android.intent.extra.SUBJECT" android:value="@string/email_subject" />我只是从Intent.java上抓取了意向的额外名称;与电子邮件相关的名称都集中在一起。
我只是刚刚发现这一点,还没有做太多的测试,但这看起来肯定适用于我的GMail邮件客户端。
此外,如果有任何帮助的话,我确实成功地使用了mailto的"body“:URI,例如
mailto:example@example.com?subject=This%20is%20a%20subject&body=This%20is%20a%20body我不知道对我的mailto URL进行URL编码是否有帮助;我只是出于习惯,来自网络背景。但这肯定是有效的,并在GMail和K9邮件应用程序中设置了主体。
发布于 2011-08-05 22:21:37
显然,您可以在普通浏览器mailto: uri上使用许多可以使用的querystring参数。
因此,要实现这一点,您只需像这样使用它们。
<intent
android:action="android.intent.action.VIEW"
android:data="mailto:xxxxx@xxxxxxx.com?subject=this is a test subject"
/>https://stackoverflow.com/questions/6948479
复制相似问题