简体   繁体   English

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

[英]Android:How to send a voice as mms attachment?

I have already done a voice recording by this code: 我已经通过这段代码完成了录音:

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

and trying to share it using a share intent like this: 并试图使用这样的共享意图分享它:

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

but when my mail is setup it send via email, but i want to share it vaia mms? 但是当我的邮件设置它通过电子邮件发送,但我想分享它vaia mms? its being attatched in mms? 它被固定在mms? how to do it? 怎么做?

You can try this in my case it work perfect. 在我的情况下,你可以试试这完美。

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

But some device can't accept like Htc Desire,Htc one,lava.In Your case work perfect then paste code. 但有些设备无法接受像Htc Desire,Htc one,lava。在你的情况下工作完美然后粘贴代码。

Please try following code, 请尝试以下代码,

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM