6 android
我们可以使用ACTION_SEND打开共享对话框来共享文本
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"));
Run Code Online (Sandbox Code Playgroud)
如何使用ACTION_SEND共享文本文件.
我阅读 http://developer.android.com/training/sharing/send.html 但无法获得如何共享文本文件.
使用以下行.
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..."));
Run Code Online (Sandbox Code Playgroud)
确保文本文件路径应来自外部存储卡.动作发送不接受内部存储器中的文件.
希望这会帮助你.
| 归档时间: |
|
| 查看次数: |
4582 次 |
| 最近记录: |