標籤: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 啟動預設的郵件用戶端,多附件的問題