gpt4 book ai didi

android - 使用 ACTION_SEND 打开共享对话框以共享文件

转载 作者:行者123 更新时间:2023-11-29 14:39:29 26 4
gpt4 key购买 nike

我知道如何使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com