android 啟動預設的郵件用戶端,多附件的問題

來源:互聯網
上載者:User

標籤:android   android開發   

目前開發的app中需要發送郵件,所以需要調用android預設的郵件用戶端,並需要添加多個郵件附件,我該通過哪個組件調用預設的用戶端?用什麼組件來支援多個附件的電子郵件?

是通過下面的哪一個?
(
 Intent.ACTION_SEND, 
 Intent.ACTION_SENDTO, 
 Intent.ACTION_SEND_MULTIPLE, ...
)?

處理方法

過一遍android email的原始碼,能在結尾發現如下代碼

String subject = ...String text = ...ArrayList<Uri> attachments = ...Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);intent.putExtra(Intent.EXTRA_SUBJECT, subject);intent.putExtra(Intent.EXTRA_TEXT, text);intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);intent.setClassName("com.android.email", "com.android.email.activity.MessageCompose");try {startActivity(intent);} catch (ActivityNotFoundException anfe) {anfe.printStackTrace();}上面的代碼在 Android 4.0 到 Android 4.3時好用的,在Android 4.4 (KitKat) 版本中,activity的名字已經變成了 com.android.email.activity.ComposeActivityEmail, 


你可以試試,我沒試過...


原文地址:http://www.itmmd.com/201411/182.html 
該文章由 萌萌的IT人 整理髮布,轉載須標明出處。

android 啟動預設的郵件用戶端,多附件的問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.