Android:如何发送mms附件的声音?

时间:2012-02-25 05:59:39

标签: java android mms

我已经通过此代码录制了录音:

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?怎么做?

2 个答案:

答案 0 :(得分:4)

在我的情况下,您可以尝试这种方法,它可以完美运行。

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。在你的情况下工作完美然后粘贴代码。

答案 1 :(得分:0)

请尝试以下代码,

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");