gpt4 book ai didi

android - 如何与原始文件夹中的其他应用程序共享我的 mp3 文件

转载 作者:行者123 更新时间:2023-11-29 02:23:25 25 4
gpt4 key购买 nike

我有音频文件的回收 View ,音频文件存储在原始文件夹中。现在,我想与其他应用程序共享我的音频文件。我正在适配器类中尝试此代码。

                Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(
"android.resource://"+ context.getPackageName()+"/raw/"
+ songs[getAdapterPosition()]));
shareIntent.setType("audio/mp3");
context.startActivity(shareIntent);

但它不起作用。如何解决这个问题。

提前致谢。

最佳答案

mp3 文件在您应用的内部存储中;其他应用无法访问您应用的内部存储空间。

为了共享,首先将 mp3 文件存储到外部存储中,https://developer.android.com/guide/topics/data/data-storage

然后使用您应用中的 Content provider 提供 mp3 文件的 Uri 路径信息。

关于android - 如何与原始文件夹中的其他应用程序共享我的 mp3 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53710058/

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