我希望有一个共享操作,只会使用电子邮件选项(电子邮件,gmail ...根据已安装的应用程序)弹出选择器,并复制到剪贴板。 任何片段都会非常感激。
编辑: 这是我到目前为止所尝试的:
Intent email_intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto","", null));
email_intent.putExtra(android.content.Intent.EXTRA_SUBJECT, entry.getDisplayName());
email_intent.putExtra(android.content.Intent.EXTRA_TEXT,"");
Intent clipboardIntent = new Intent();
clipboardIntent.setComponent(new ComponentName("com.google.android.apps.docs", "com.google.android.apps.docs.app.SendTextToClipboardActivity"));
clipboardIntent.setAction(Intent.ACTION_SEND);
clipboardIntent.setType("text/plain");
clipboardIntent.putExtra(Intent.EXTRA_TEXT, "text to copy to clipboard");
Intent chooserIntent = Intent.createChooser(email_intent, "Share entry");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { clipboardIntent });
startActivity(chooserIntent);
但它只显示了电子邮件选项。 我也尝试使用自己的CopyToClipboardActivity,但结果仍然相同
答案 0 :(得分:2)
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "email body");
//emailIntent.putExtra(Intent.EXTRA_HTML_TEXT, body); //If you are using HTML in your body text
startActivity(Intent.createChooser(emailIntent, "Chooser Title"));