Reputation: 9
With this snippet of code I share an audio:
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"));
They are contained in the 'raw' folder. I can send them through whatsapp, but in a format without extension that does not run. On the other hand, when saved on google drive, it recognizes it as a music file and runs, though it does not have extension. All audios in the raw folder are in .mp3 format
Upvotes: 1
Views: 45
Reputation: 1006614
The documentation for EXTRA_STREAM
says that you should use a Uri
with a content
scheme. So, for example, you could use FileProvider
to serve up some local file that contains your audio.
Upvotes: 1