很好的一天!所以基本上我创建一个文件,然后通过电子邮件发送,一切正常,但当gmail应用程序打开时,有一条消息“无法附加文件”。请给我任何建议我该怎么办谢谢!我的代码:
File file = new File(Environment.getExternalStoragePublicDirectory("Android/data/app.myapp")+"/", FILE_NAME);
FileOutputStream outputStream = null;
try {
file.createNewFile();
outputStream = new FileOutputStream(file, true);
outputStream.write(textToWrite.getBytes());
outputStream.flush();
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
if(!file.exists())
{
Toast.makeText( MainActivity.this,"doesnt exist",Toast.LENGTH_SHORT).show();
}
if( file.exists())
{
Toast.makeText(getBaseContext(), "exist", Toast.LENGTH_LONG).show();
}
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_SUBJECT, "Send Text File");
email.putExtra(Intent.EXTRA_TEXT,"");
email.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + file.getAbsoluteFile()));
email.setType("message/rfc822");
startActivity(Intent.createChooser(email , "Send Text File"));
暂无答案!
目前还没有任何答案,快来回答吧!