如何在android中使用意图发送.text文件? [英] How to send .text file by using intent in android?
本文介绍了如何在android中使用意图发送.text文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用下面的代码发送邮件,我需要也只使用 gmail 发送一个 .text 文件.我该怎么做?请问有人可以帮我吗?
I am sending a mail by using below code and i need to send a .text file also using gmail only. How can i do it? Please can any one help me?
Intent send = new Intent(Intent.ACTION_SENDTO);
String uriText = "mailto:" + Uri.encode("") +
"?subject=" + Uri.encode("Sample Text") +
"&body=" + Uri.encode("Hi");
Uri uri = Uri.parse(uriText);
send.setData(uri);
startActivity(Intent.createChooser(send, "Send mail..."));
提前致谢.
推荐答案
File sd = Environment.getExternalStorageDirectory();
File fileDir= new File(sd, "dir_path");
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_STREAM, Uri.parse(fileDir.getAbsolutePath() + "/"
+ FILE_TXT
startActivity(Intent.createChooser(email , "Email: Text File"));
这篇关于如何在android中使用意图发送.text文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文