更新时间:2023-02-01 17:28:49
像这样更改代码。
发件人
File file = new File(Environment.getExternalStorageDirectory(), "Email-Ghap/Emails.txt");
到
File file = new File(Environment.getExternalStorageDirectory() + "/" + "Email-Ghap/Emails.txt");
来自:
sharingIntent.setType("*/txt");
到
sharingIntent.setType("text/*");
所以您的最终代码看起来像
so yourFinal Code Looks Like
File file = new File(Environment.getExternalStorageDirectory().toString() + "/" + "abc.txt");
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath()));
startActivity(Intent.createChooser(sharingIntent, "share file with"));