Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/186.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 共享时只有google drive可以识别音频文件_Android - Fatal编程技术网

Android 共享时只有google drive可以识别音频文件

Android 共享时只有google drive可以识别音频文件,android,Android,通过这段代码,我分享了一段音频: Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("audio/mp3"); sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse( "android.resource://"+getPackageName()+"/raw/"+

通过这段代码,我分享了一段音频:

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("audio/mp3");
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(
                "android.resource://"+getPackageName()+"/raw/"+
                getResources().getResourceEntryName(audiosRage[position])));
startActivity(Intent.createChooser(sharingIntent, "Compartilhar via"));

它们包含在“原始”文件夹中。我可以通过whatsapp发送它们,但格式没有扩展,无法运行。另一方面,当保存在google drive上时,它会将其识别为音乐文件并运行,尽管它没有扩展名。raw文件夹中的所有音频都是.mp3格式的

表示您应该使用
Uri
内容
方案。因此,例如,您可以使用
FileProvider
提供一些包含您音频的本地文件。

很少有Android应用程序会使用
Android.resource
方案识别
Uri
。您认为我应该怎么做才能与Whatsapp共享?