起初你会想到"等等,这个问题是重复的!".继续阅读.
我正在尝试使用Intent ACTION_SENDTO(使用电子邮件URI作为数据),以便只有电子邮件应用程序响应.
(使用ACTION_SEND启动标准"SEND"选择器而没有数据URI意味着非电子邮件应用程序(如Google Drive)也会响应).
我的问题是附件适用ACTION_SEND于所有设备,但是 - 当ACTION_SENDTO只使用某些设备正确附加文件时.Nexus 7可以使用,但三星Galaxy Tab和Acer Iconia 没有.
您可以在下面看到不同的方法:
String email = getActivity().getResources().getString(R.string.supportEmail);
String subject = getActivity().getResources().getString(R.string.sFeedback);
subject = String.format(subject,
getActivity().getResources().getString(R.string.productName));
String content = getActivity().getResources().getString(R.string.whatFeedbackWouldYouLikeToProvide) + "\n\n" +
mMessage.getText().toString();
File toSend = new File(outfile);
if(toSend.exists()) {
Log.e("Feedback", "File path: " + toSend.getAbsolutePath());
Intent emailIntent = new Intent(android.content.Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto:" +email));
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.fromFile(toSend));
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, content);
/* Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("message/rfc822");
emailIntent.putExtra(Intent.EXTRA_EMAIL , new String[]{email}); …Run Code Online (Sandbox Code Playgroud)