我正在通过电子邮件发送文件。发送的文件但其大小仍为0kb,文件丢失所有数据。 有没有办法做到这一点,文件仍然是原始内容? 我正在使用以下代码。为什么在电子邮件中作为附件发送的文件接收大小为0kb的文件?
File f=new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/SMSZip/a1.rar");
Uri uri = Uri.fromFile(f);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"[email protected]"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse(f.getAbsolutePath()));
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getApplicationContext(), "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
i.putExtra(Intent.EXTRA_STREAM,Uri.parse(f.getAbsolutePath())); 这应该是i.putExtra(Intent.EXTRA_STREAM,uri);尝试这个。 – user370305 2012-02-28 08:28:48