我正在尝试让用户在点击按钮时给我发电子邮件,并使用此代码执行此操作。虽然它有效,但它带来了许多其他无法处理电子邮件的应用程序,如Twitter和Facebook。有什么遗漏?
String[] email = {"evan@example.com"};
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_EMAIL,email);
context.startActivity(sendIntent);
答案 0 :(得分:0)
// start the activity
context.startActivity(sendIntent);
// start the activity asking the user how to send the email
context.startActivity(Intent.createChooser(sendIntent, "Email:"));
所以你需要删除最后一行。
请参阅http://developer.android.com/reference/android/content/Intent.html
答案 1 :(得分:0)
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent .setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"evan@example.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, msg);
startActivity(Intent.createChooser(emailIntent, "Send mail"));