如何使用Intent.ACTION_SENDTO附加文件...我使用了以下代码,但文件没有附加....我在一些帖子中读到这是不可能的
Uri mail= Uri.fromParts("mailto",message, null);
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, mail);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, sub);
emailIntent.putExtra(Intent.EXTRA_TEXT,mailcontent);
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(Environment.getExternalStorageDirectory()+"Folder/abc.txt"));
答案 0 :(得分:0)
请参阅以下链接:Trying to attach a file from SD Card to email看起来他们经过多次调试后才能正常工作。所以你的问题可能已经得到了回答。
答案 1 :(得分:0)
以下适用于我:
File tmpDir = new File(Environment.getExternalStorageDirectory() + "/temp/");
File tmpFile = new File(tmpDir.getAbsolutePath() + "/" + attachedFile.getName());
Uri uri = Uri.fromFile(tmpFile);
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, uri);
我认为Uri.fromFile()
部分可能是此处的关键,或者在file://
位之前。