javaandroidaudioshareshare-intent

Share audio and text together


I have an app with different sounds. I'd like to share a sound(audio) together with a text.

If I share only a sound it works:

share.putExtra(Intent.EXTRA_STREAM, Uri.parse(Environment.getExternalStorageDirectory().toString() + "/audio.mp3"));
                share.setType("audio/mp3");
                startActivity(Intent.createChooser(share, "Share via..."));

Now I tried to add a text:

share.putExtra(Intent.EXTRA_STREAM, Uri.parse(Environment.getExternalStorageDirectory().toString() + "/audio.mp3"));
                share.setType("audio/mp3");
                sharetext.putExtra(Intent.EXTRA_TEXT,"This should be under the audio file after sharing");
                startActivity(Intent.createChooser(share, "Share via..."));

But still only the audio get shared.

How does it works? And if this isn't possible is there an other way to do this? Thank you very much! :)


Solution

  • It really depends on what app you end up choosing when you're using the chooser to share the audio file as it's up to the chosen application to decide whether or not to use the supplied text set by EXTRA_TEXT. In short, you really don't have much control over this.