2

我知道如何使用 ACTION_SEND 分享 A 文本。

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 但从这个链接中得到的信息不多。

4

1 回答 1

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"));
于 2013-04-18T09:31:16.227 回答