使用ACTION_SEND共享文本文件 [英] Sharing Text File using ACTION_SEND
本文介绍了使用ACTION_SEND共享文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以使用ACTION_SEND打开共享对话框以共享文本
We can open share dialog using ACTION_SEND to share text
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Download Link: Android play store link");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, "Share This App"));
如何使用ACTION_SEND共享文本文件.
How can I use ACTION_SEND to share a text file.
我阅读了 http://developer.android.com/training/sharing/send.html 但无法获取共享文本文件的方法.
I read http://developer.android.com/training/sharing/send.html but could not get how to share text file.
推荐答案
使用以下行.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("*/*");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"me@gmail.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"go on read the emails");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromfile(new File(yourtextfilepath));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
确保您的文本文件路径应来自外部存储卡.动作发送不会接受内部存储器中的文件.
Make sure that your text file path should be from external memory card. Action send wont accept the files from internal memory.
希望这会对您有所帮助.
Hope this will help you.
这篇关于使用ACTION_SEND共享文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文