簡體   English   中英

使用intent android通過MMS發送音頻

[英]sending audio throught MMS using intent android

我是Android新手。 我正在嘗試發送帶有m4a格式(或其他,如AMR或3GP)的音頻文件的彩信。 要做到這一點,我使用一個意圖,但它永遠不會發送我的彩信。 這是我正在使用的代碼:

Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/m4a");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + new Environment.getExternalStorageDirectory().getPath()+"/recordaudio.m4a")));
startActivity(share);

我的音頻播放速度不超過30kb。 請問你能幫幫我嗎 ? 抱歉英語我是法國人

File audiofile = new File(directory,"/recordaudio.m4a");                                        
byte     fileContent[] = new byte[(int) audiofile.length()];                                            
InputStream input = new FileInputStream(audiofile);    

int data = input.read();                                        
while(data != -1) {                                           
    data = input.read(fileContent);                                     
}
input.close();
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, mPhoneNumber);
sendIntent.setType("audio/*");
sendIntent.putExtra(Intent.EXTRA_STREAM, fileContent);
startActivity(sendIntent);*

首先,非常感謝你的幫助!!!! 我試過這個代碼而mms不發送......你能幫我一次嗎?

您發送的是音頻文件的Uri,但不是音頻文件本身。

在意圖中發送音頻文件不是一個好主意

如果您仍希望發送音頻文件的byte []在intent中 - 使用InputStream從給定的URI下載這些字節后

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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