2012-02-25 52 views
1

我已經通過這個代碼做了錄音: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?它正在以毫米爲單位?怎麼做?

+0

@NNirupoma Saha Chaiti接受的答案是你的工作。你必須在htc device.i有htc一個不能附加文件測試。 – Harshid 2013-01-11 11:43:32

+0

我在做類似的事情! http://stackoverflow.com/questions/14452808/sending-and-receiving-mms-in-android – toobsco42 2013-01-22 06:45:34

回答

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渴望,HTC之一,lava.In你的情況下,工作完美然後粘貼代碼。

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

但我在這裏attatching音頻,它會工作嗎? – 2012-02-25 06:05:28

+0

是,在url變量,設置您的音頻文件 – Android 2012-02-25 06:11:51

+1

的我也一樣ü說的路徑,但沒有工作:( 其說 抱歉,你不能在你的信息添加圖片? 有沒有什麼具體的文件格式? – 2012-02-25 06:20:13