2012-05-07 27 views
4

我想創建一個意圖,將啓動附加的圖像文件和一些預定義的文本出現在郵件正文中的MMS應用程序。Android MMS意圖與圖像和正文文本

到目前爲止,我已經能夠完成或者,但不能同時完成。

事情我已經嘗試過(對自己的成績):

sendIntent = new Intent(android.content.Intent.ACTION_SEND,Uri.parse("mms://")); 
sendIntent.setType("image/gif"); 
sendIntent.putExtra(Intent.EXTRA_STREAM, imgStreamUri); 
sendIntent.putExtra("sms_body", "HelloWorld"); 
startActivity(Intent.createChooser(sendIntent,"Send"));  
/********** 
Image file is attached but no text added to message body. 
**********/ 

sendIntent = new Intent(android.content.Intent.ACTION_SEND); 
sendIntent.setType("image/gif"); 
sendIntent.putExtra(Intent.EXTRA_STREAM, imgStreamUri); 
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "HelloWorld"); 
sendIntent.putExtra(Intent.EXTRA_TITLE, "WorldHello"); 
startActivity(Intent.createChooser(sendIntent,"Send")); 
/********** 
Image file is attached but no text added to message body(or subject or anything). 
**********/ 

有誰知道我怎麼能把這兩個主體文本和圖像文件,以彩信的意圖,將與適當的啓動默認的消息傳遞應用程序項目填入?

編輯:測試代碼@lenik在答案中提供。這是工作的一些設備,這裏是我的發現

正常工作:

  • 史詩4G(銀河S)
  • 史詩的4G觸摸(GALAXY S II)
  • 的Galaxy Nexus(ICS 4.0。 4)
  • HTC慾望(升級Froyo 2.2)
  • 摩托羅拉光子

伊馬GE連接但沒有文字:

  • 的Sidekick4克
  • 三星變換超

任何人都知道,如果我基本上s.o.l.在這種方式不能正常工作的設備上?

回答

8

下面的代碼對我的作品:

Intent intent = new Intent(Intent.ACTION_SEND); 
intent.putExtra("sms_body", "Hi how are you"); 
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/file.gif"))); 
intent.setType("image/gif"); 
startActivity(Intent.createChooser(intent,"Send")); 
+0

我沒有得到任何的文字添加。你運行什麼設備? – FoamyGuy

+0

適用於我的HTC Desire(Froyo 2.2)和Galaxy Nexus(ICS 4.0.4)。 – lenik

+0

請嘗試使用我的sorce **逐字**,最有可能的問題是與你的'imgStreamUri'參數有關,如果它的內容不正確,文本或文件在MMS消息中顯示不正確。 – lenik