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

muh*_*sva 3 email android android-button

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

kam*_*eny 7

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

以下是来自网络的示例:

 /* 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..."));
Run Code Online (Sandbox Code Playgroud)