How to share Audio file from Android App Programmatically Example

Please follow and like us:

share audio file from android app example

In this example I have explained how to share Audio file from Android App with simple code. here I also add to share Audio file directly to WhatsApp from your Android App. Let’s explore sharing audio or mp3 from Android App Example…

Share Audio from Android App Example

add following code in your java file

		File f=new File("full audio path");
		Uri uri = Uri.parse("file://"+f.getAbsolutePath());
		Intent share = new Intent(Intent.ACTION_SEND);
		share.putExtra(Intent.EXTRA_STREAM, uri);
		share.setType("audio/*");
		share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
		context.startActivity(Intent.createChooser(share, "Share audio File"));

Share Audio directly to WhatsApp from your app

		File f=new File("full audio path");
		Uri uri = Uri.parse("file://"+f.getAbsolutePath());
		Intent share = new Intent(Intent.ACTION_SEND);
                share.setPackage("com.whatsapp");
		share.putExtra(Intent.EXTRA_STREAM, uri);
		share.setType("audio/*");
		share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
		context.startActivity(Intent.createChooser(share, "Share audio File"));

Hope, you like our simple example of how to share Audio from android app.

nirav kalola