我需要为用户提供功能,用户可以通过发送电子邮件来共享一些数据。我使用了下面的代码。
Intent email = new Intent(android.content.Intent.ACTION_SENDTO);
email.setType("message/rfc822");
email.putExtra(Intent.EXTRA_EMAIL, new String[] { to });
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(email,"Choose an Email client :"));
这显示电子邮件、gmail、Skype 和通过蓝牙发送供用户选择。我不希望用户在此列表中显示 Skype,通过蓝牙发送。我需要做什么 ?我的手机里有 WhatsApp,它做同样的事情,但没有在列表中显示电子邮件、蓝牙(设置->帮助->联系人->...)。仅在列表中显示电子邮件和 Gmail。我也需要这样做。
最佳答案
试试这个:
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto","email@email.com", null));
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(intent, "Choose an Email client :"));
如果您没有特定的收件人 - 像这样:
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", "", null));
关于android - 单击按钮时从 Android 应用程序发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21720640/