3

I m new in Android. I am trying to send an MMS with audio file, with m4a format (or other, like AMR, or 3GP). To do this I use an intent but it never sends my MMS. Here isfolowing code I am using:

Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/m4a");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + new Environment.getExternalStorageDirectory().getPath()+"/recordaudio.m4a")));
startActivity(share);

And my audio flie does not reach more than 30kb. Could you help me please ? Sorry for the english I'm French

File audiofile = new File(directory,"/recordaudio.m4a");                                        
byte     fileContent[] = new byte[(int) audiofile.length()];                                            
InputStream input = new FileInputStream(audiofile);    

int data = input.read();                                        
while(data != -1) {                                           
    data = input.read(fileContent);                                     
}
input.close();
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, mPhoneNumber);
sendIntent.setType("audio/*");
sendIntent.putExtra(Intent.EXTRA_STREAM, fileContent);
startActivity(sendIntent);*

First of all , thank you very much for your help !!!! I tried this code and mms is not send... Could you help me again ??

user1106464
  • 111
  • 11

1 Answers1

1

What you are sending is the Uri of the audio file but not the audio file itself.

Its not a good idea to send the audio file in the intent

If you still want to send put the byte[] of the audio file in the intent -- after downloading these bytes from the given URI using InputStream

Rajdeep Dua
  • 11,190
  • 2
  • 32
  • 22