Share Audio File

Asked

Viewed 459 times

4

I recorded an audio file, like . 3gp, through the phone microphone, in my own application 'Android'.

I would like to know how to share via Intent, because I only share texts.

Note: I have the address of the file and everything else. I only need the function of sharing file, either audio or video!

1 answer

2

With the device path you can use:

final Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("audio/3gpp");
shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse("file://"+path+filename));
startActivity(Intent.createChooser(shareIntent, getString(R.string.share_sound)));

Function option for Whatsapp, for example:

public void onClick(View v) {
                    final Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
                    String audioClipFileName="audio.3gp";
                    shareIntent.setType("audio/3gpp");
                    shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse("file://"+"/sdcard/"+audioClipFileName));
                    shareIntent.setPackage("com.whatsapp");
                    startActivity(Intent.createChooser(shareIntent, "Compartilhando no whatsapp"));
                }

IF YOUR PATH IS EXTERNAL. Remembering the Meuapp/Images folders should be created in the app installation:

Environment.getExternalStorageDirectory().getAbsolutePath() +
                "/MeuApp/Imagens/";

For more details, click here.

  • The file is in the folder 'date/date/application/files/folder/file.3gp'. How do I put it in this Uri? Lollipop

  • UPDATED!......

Browser other questions tagged

You are not signed in. Login or sign up in order to post.