Mr *_*son 64 java android attachment android-intent
可能重复:
来自内部存储的电子邮件
收件人正在接收电子邮件,但没有附件.这是代码,任何专家都知道我哪里出错了?
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"email@example.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "subject here");
intent.putExtra(Intent.EXTRA_TEXT, "body text");
File root = Environment.getExternalStorageDirectory();
File file = new File(root, xmlFilename);
if (!file.exists() || !file.canRead()) {
Toast.makeText(this, "Attachment Error", Toast.LENGTH_SHORT).show();
finish();
return;
}
Uri uri = Uri.parse("file://" + file);
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Send email..."));
Run Code Online (Sandbox Code Playgroud)
我没有得到任何祝酒词.谢谢.
Com*_*are 58
尝试:
Uri.fromFile(file);
Run Code Online (Sandbox Code Playgroud)
代替:
Uri.parse("file://" + file);
Run Code Online (Sandbox Code Playgroud)
另外,尝试text/xml使用您的MIME类型,假设这是一个XML文件,如您的变量名所示.
Fem*_*emi 13
该文件可能不是世界可读的.
编辑:的确如此.试着这样做:
Uri uri = Uri.parse("file://" + file.getAbsolutePath());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
61921 次 |
| 最近记录: |