I am developing a Android Application, In which I need to send voice by email. Ans I want that such flow, record a voice and send mail as a audio file in attachment. and I want that voice should not remaining in phone or SD card. is it possible ?
Asked
Active
Viewed 2,731 times
1

Praveenkumar
- 24,084
- 23
- 95
- 173

Jignesh Ansodariya
- 12,583
- 24
- 81
- 113
-
Yes it's possible but what have you tried? Have you searched to find out how it's possible to send *any* type of attachment by email? Audio is no more special than an image, for example. – Squonk Jun 02 '12 at 07:12
2 Answers
1
Here is what you need, It works with me.......
Uri uri = Uri.fromFile(new File(YOUR_DIR, YOUR_FILE_NAME)));
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT, "TITLE");
it.putExtra(Intent.EXTRA_TEXT, "CONTENT");
it.putExtra(Intent.EXTRA_STREAM, uri);
it.setType("audio/rfc822");
context.startActivity(Intent.createChooser(it,context.getString(R.string.share)));

Tai Tran
- 1,406
- 3
- 15
- 27
-
How will this delete the voice recording after it has been sent as an attachment? – Squonk Jun 02 '12 at 07:22
0
One of the solution according to me is..
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "some text");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("audio/3gp");
startActivityForResult(Intent.createChooser(sendIntent, "Send mail..."),0);
with above code you can send the voice as email attachment and in the onActivityResult() you can delete the file from sdcard/memory.

Shankar Agarwal
- 34,573
- 7
- 66
- 64
-
2A 3rd-party email app isn't necessarily going to return a 'result' when called with `startActivityForResult(...)`. – Squonk Jun 02 '12 at 07:17