如何在Android中的電子郵件中附加多個文件? 是否有任何權限需要多個文件附件的意圖? 我想用putParcelableArrayListExtra(Intent.EXTRA_STREAM,ArrayList uriList)方法,但仍然懷疑是否Uri類是<?是否擴展了Parcelable >。 我無法附加任何文件到電子郵件。Android將多個文件從SD卡連接到電子郵件
這是我的代碼::
Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
sendIntent.setType("plain/text");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"[email protected]"});
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Accident Capture");
sendIntent.putExtra(Intent.EXTRA_TEXT, emailBody);
ArrayList<Uri> uriList = getUriListForImages();
sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList);
Log.d(TAG, "Size of the ArrayList :: " +uriList.size());
FormHolderActivity.this.startActivity(Intent.createChooser(sendIntent, "Email:"));
和getUriListForImages()這個方法被定義爲波紋管-----
private ArrayList<Uri> getUriListForImages() {
ArrayList<Uri> uriList = new ArrayList<Uri>();
String imageDirectoryPath = Environment.getExternalStorageDirectory().getAbsolutePath()+ "/accident/";
File imageDirectory = new File(imageDirectoryPath);
String[] fileList = imageDirectory.list();
if(fileList.length != 0) {
for(int i=0; i<fileList.length; i++)
{
String file = "file://" + imageDirectoryPath + fileList[i];
Log.d(TAG, "File name for Uri :: " + file);
Uri uriFile = Uri.parse(file);
uriList.add(uriFile);
Log.d(TAG, "Image File for Uri :: " +(file));
}
}
return uriList;
}
,主題和電子郵件的身體來了我在SD卡的事故文件夾中有圖像(我正在使用2.1 API級別7),但沒有附加任何內容,即使在logcat.Arraylist中也沒有例外也沒問題(意味着長度正常,文件名也可以)。任何人都可以幫我解決這個問題嗎?
那麼我怎樣才能附加多個文件?有沒有其他方法可以做到這一點? –