ACTION_SENDTO 用于发送电子邮件 [英] ACTION_SENDTO for sending an email
本文介绍了ACTION_SENDTO 用于发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Android 2.1 中执行以下代码片段时遇到当前不支持此操作"错误情况.这段代码有什么问题?
I am experiecing "This action is not currrently supported" error condition when execute the following code snippet in Android 2.1. What is wrong with the snippet?
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
Uri uri = Uri.parse("mailto:myemail@gmail.com");
intent.setData(uri);
intent.putExtra("subject", "my subject");
intent.putExtra("body", "my message");
startActivity(intent);
}
推荐答案
如果您使用 ACTION_SENDTO
,putExtra()
无法向意图添加主题和文本.使用 setData()
和 Uri
工具添加主题和文本.
If you use ACTION_SENDTO
, putExtra()
does not work to add subject and text to the intent. Use setData()
and the Uri
tool add subject and text.
这个例子对我有用:
// ACTION_SENDTO filters for email apps (discard bluetooth and others)
String uriText =
"mailto:youremail@gmail.com" +
"?subject=" + Uri.encode("some subject text here") +
"&body=" + Uri.encode("some text here");
Uri uri = Uri.parse(uriText);
Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(uri);
startActivity(Intent.createChooser(sendIntent, "Send email"));
这篇关于ACTION_SENDTO 用于发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文