ACTION_SENDTO发送电子邮件 [英] ACTION_SENDTO for sending an email
本文介绍了ACTION_SENDTO发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我experiecing当Android 2.1系统中执行以下code段这个动作是不是currrently支持错误情况。什么是错的片段?
公共无效的onClick(视图v){
意向意图=新的意图(Intent.ACTION_SENDTO);
开放的我们的uri = Uri.parse(电子邮件地址:myemail@gmail.com);
intent.setData(URI);
intent.putExtra(主体,我的主题);
intent.putExtra(身体,我的信息);
startActivity(意向);
}
解决方案
如果您使用 ACTION_SENDTO
, putExtra()
不起作用添加主题和文本的意图。使用使用setData()
和乌里
工具添加主题和文本。
本示例为我的作品:
电子邮件应用程序// ACTION_SENDTO过滤器(丢弃蓝牙等)
字符串uriText =
电子邮件地址:youremail@gmail.com+
?主题=+ Uri.en code(一些主题文本这里)+
&放大器;身体=+ Uri.en code(一些文字在这里);
开放的我们的uri = Uri.parse(uriText);
意图sendIntent =新的意图(Intent.ACTION_SENDTO);
sendIntent.setData(URI);
startActivity(Intent.createChooser(sendIntent,发送电子邮件));
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);
}
解决方案
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.
This example works for me:
// 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屋!
查看全文