How to send recorded voice in email?

2019-04-16 02:34发布

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 ?

2条回答
聊天终结者
2楼-- · 2019-04-16 02:57

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)));
查看更多
We Are One
3楼-- · 2019-04-16 02:57

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.

查看更多
登录 后发表回答