Java Android:如何将语音作为彩信附件发送?
我已经通过以下代码进行了语音录制:Java Android:如何将语音作为彩信附件发送?,java,android,mms,Java,Android,Mms,我已经通过以下代码进行了语音录制: recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_
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"));
但当我的邮件设置好后,它会通过电子邮件发送,但我想通过彩信共享它?它被附加在彩信中?如何操作?请尝试以下代码
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");
请尝试以下代码
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");
你可以试试这个在我的情况下,它的工作完美
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.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。在您的情况下,请完美工作,然后粘贴代码。我也按您所说的做了,但没有工作:它说抱歉,您不能在邮件中添加此图片?有任何特定的文件格式吗?@nirupmasahachaiti你有哪个设备?因为htc出现错误。我做了与你说的相同的操作,但不起作用:它说抱歉,你不能在你的消息中添加此图片?有任何特定的文件格式吗?@Nirupoma Sahahachaiti您有哪个设备?因为htc get错误。@NNirupoma Saha Chaiti接受的答案对您有效。您必须在htc设备中进行测试。我有htc one无法附加的文件。我正在做类似的事情@NNirupoma Saha Chaiti接受的答案是为你们工作。你们必须在htc设备上测试。我有htc一个不能附加的文件。我在这里做类似的事情!!!