android:带模板的电子邮件

android:带模板的电子邮件,android,email,Android,Email,我正在从我的应用程序发送电子邮件。 我想知道是否有办法定义模板,例如: subject: Regarding {{title}} Body: You may be interested in the product {{title}} \b {{desc}} 我想在一些资源文件中定义这个模板 感谢您的帮助和时间。您可以输入strings.xmlw/字符串格式字符,如%d%s%f..,并使用string.format() 如果其他人有更好的想法就好了:)只需根据构建mailto URL,其中

我正在从我的应用程序发送电子邮件。 我想知道是否有办法定义模板,例如:

subject: Regarding {{title}} 
Body: You may be interested in the product {{title}} \b {{desc}} 
我想在一些资源文件中定义这个模板


感谢您的帮助和时间。

您可以输入
strings.xml
w/字符串格式字符,如
%d%s%f..
,并使用
string.format()


如果其他人有更好的想法就好了:)

只需根据构建mailto URL,其中包括主题和其他字段。因此,最终您将拥有可用于启动电子邮件发件人活动的URI:

Uri uri=Uri.parse("mailto:example@example.com?subject=Here goes test message");
intent = new Intent(Intent.ACTION_SENDTO, uri);
activity.startActivity(intent);

此外,如果需要使用String.format(String,Object…)对字符串进行格式化,则可以根据需要以编程方式构造mailto URL

格式化字符串,然后可以将格式参数放入字符串资源中。例如,使用以下资源:Hello,%1$s!您有%2$d封新邮件。在此示例中,格式字符串有两个参数:%1$s是字符串,%2$d是十进制数。您可以使用应用程序中的参数格式化字符串,如下所示:Resources res=getResources();String text=String.format(res.getString(R.String.welcome_messages)、用户名、邮件数);这个答案是我从