【问题标题】:How to share my mp3 file with other apps from raw folder如何与原始文件夹中的其他应用程序共享我的 mp3 文件
【发布时间】:2018-12-10 16:46:24
【问题描述】:

我有一个音频文件的回收器视图,音频文件存储在 raw 文件夹中。现在,我想与其他应用程序共享我的音频文件。我正在适配器 clss 中尝试此代码。

                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);

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

提前致谢。

【问题讨论】:

    标签: android android-recyclerview android-mediaplayer media-player


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多