如何在Android上创建电子邮件按钮?

时间:2011-07-05 12:57:38

标签: android email android-button

我是Android编程的初学者。我想在我的程序上创建特定的电子邮件按钮。 (例如,电子邮件地址为info@abcde.tv)。当我点击电子邮件按钮时,邮件程序应该打开。我怎样才能做到这一点?

2 个答案:

答案 0 :(得分:6)

您需要使用特殊选项启动意图。

以下是网络上的一个例子:

 /* Create the Intent */
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

/* Fill it with Data */
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"to@email.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Text");

/* Send it off to the Activity-Chooser */
context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));

答案 1 :(得分:2)

如果你得到No应用程序可以执行此操作错误,
只需使用您的模拟器创建一个电子邮件帐户。
Android无法从不存在的电子邮件帐户发送邮件。