Share audio file

4

I recorded a .3gp audio file through my phone's microphone in my own Android application.

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

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

    
asked by anonymous 01.07.2015 / 14:52

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 MyApp / Images folders should be created in the app install:

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

For more details, click here.

    
01.07.2015 / 14:56