How to send recorded voice in email?

本秂侑毒 提交于 2019-12-06 12:29:02

问题


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 ?


回答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)));



回答2:


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.



来源:https://stackoverflow.com/questions/10860499/how-to-send-recorded-voice-in-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!