[英]Android:How to send a voice as mms attachment?
我已经通过这段代码完成了录音:
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
+"test.3gp");
try {
recorder.prepare();
} catch (IOException io) {
Toast.makeText(getApplicationContext(), "Record File", Toast.LENGTH_LONG).show();
}
recorder.start();
并试图使用这样的共享意图分享它:
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("video/3gp");
sharingIntent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/Downloadtest.3gp");
startActivity(Intent.createChooser(sharingIntent, "Share via"));
但是当我的邮件设置它通过电子邮件发送,但我想分享它vaia mms? 它被固定在mms? 怎么做?
在我的情况下,你可以试试这完美。
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("address", "9999999999");
sendIntent.putExtra("sms_body", "if you are sending text");
final File file1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath(),"Downloadtest.3gp");
Uri uri = Uri.fromFile(file1);
Log.e("Path", "" + uri);
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
sendIntent.setType("video/3gp");
startActivity(sendIntent);
但有些设备无法接受像Htc Desire,Htc one,lava。在你的情况下工作完美然后粘贴代码。
请尝试以下代码,
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");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.