簡體   English   中英

Android:如何發送mms附件的聲音?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM