2

I have a problem, I'm triying to send a mp3 file to gmail.

My code works good so far for whatsapp, hotmail, bluetooth... but it doesn't work with gmail

This is my code:

File sdCard = Environment.getExternalStorageDirectory();
String path = sdCard.getAbsolutePath() + "/" +"miApp"+"/tono.mp3";

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("audio/mp3");
intent.putExtra(Intent.EXTRA_SUBJECT, "Asunto");
intent.putExtra(Intent.EXTRA_TEXT, "Prueba");
intent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file:///" + path));
startActivity(intent);

I try with various types of mime but with the same results

  • "audio/x-mpeg-3"
  • "video/mpeg"
  • "video/x-mpeg"
  • "audio/mpeg"

What's wrong?

j0k
  • 22,600
  • 28
  • 79
  • 90
  • 1
    Could this be of any help: http://stackoverflow.com/questions/2197741/how-to-send-email-from-my-android-application It has slightly different code than yours. – Bart Friederichs Nov 27 '12 at 08:11

1 Answers1

0

This worked for me

Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setType("audio/mp3");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/miApp/tono.mp3"));
startActivity(i);
Talha
  • 12,673
  • 5
  • 49
  • 68