我知道如何使用 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但无法从此链接中获得太多信息。
最佳答案
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"));
关于android - 使用 ACTION_SEND 打开共享对话框以共享文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16030711/