My app use MP3 files with MediaPlayer, i want to make a button than will share an MP3 file to whatsapp.
my code is this:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
String audioClipFileName="bell.mp3";
sendIntent.setType("audio/mp3");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+"/sdcard/"+audioClipFileName));
startActivity(sendIntent);
but its not working.why is not working?how can i solve this issue?
You need use Environment and not hardcode path, for example, if your file is in sdcard root use a code like this:
If a resource use this:
Or resource ID
Any error please share logcat