我知道如何使用ACTION_SEND分享文字。
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Download Link https://play.google.com/store/apps/details?id=com.mtracker2051");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, "Share This App"));
我想使用ShareDialog共享文本文件。 我怎么能这样做。
我在这里阅读了http://developer.android.com/training/sharing/send.html,但是从这个链接中得不到多少。
答案 0 :(得分:7)
String fileName = ...
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("*/*");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"Share File"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "File Name");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(fileName)));
startActivity(Intent.createChooser(emailIntent, "Share File"));