Can't share audio with Facebook Messenger on Android: "Sorry, Messenger was unable to process this file"
<p>I am using the following piece of code to share an audio file located on a device:</p>

<pre><code>Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://pathToFile"));
intent.setType("audio/*");
activity.startActivity(Intent.createChooser(intent, "Share..."));
</code></pre>

<p>Android opens the system Share dialog where you can select an appropriate app to handle the share intent. Audio files get successfully shared with Gmail, WhatsApp, Telegram and Google Drive.</p>

<p>But Messenger shows the following error:</p>

<p><a href="https://i.stack.imgur.com/Ys2I1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ys2I1.png" alt="enter image description here"></a></p>

<p>However, when I try to share the same file using Android's Download app, it all works just fine with Messenger.</p>

<p><a href="https://i.stack.imgur.com/ykift.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ykift.png" alt="enter image description here"></a></p>

<p>Why does Messenger not process my share request correctly, while all the other apps do, and what needs to be changed in my code so it would work the same way as sharing from the Download app (so it would work for Messenger)?</p>