how to share audio file in android programmatically
Share audio file in android both from mobile internal memory and from your application raw folder. In some cases we required to send our audio file to other user using intent here is the complete code. Share audio fie to Facebook, Mesenger, Whatsapp, Email or any other sharing intent which support audio file sharing. Android single button to play and pause music.
In this first example get code of share audio file from Mobile own internal or SD card memory.
//Keep test.pcm or any other format audio file in your Memory card. Otherwise it will not work.
String sharePath = Environment.getExternalStorageDirectory().getPath() + “test.pcm”;
Uri uri = Uri.parse(sharePath);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType(“audio/*”); //Any audio file type you can share.
//share.setType(“audio/mp3”); //For particular audio file type.
startActivity(Intent.createChooser(share, “Share Sound File”));