最近碰到android email 郵件轉發 附件不能轉發問題,然後就仔細研究後,發現這個問題的解決很簡單,所以對其進行了解決,並在自己的機子上進行了測試,下面我把代碼給大家發出來。
在MessageCompose.java類中添加這兩個方法:
private boolean findAttachmentWithMessageId(Context context,long messageId){
Uri uri = ContentUris.withAppendedId(Attachment.MESSAGE_ID_URI,messageId);
Cursor c = context.getContentResolver().query(uri,Attachment.CONTENT_PROJECTION,null,null,null);
boolean allAttachmentsDownload = true;
try{
int count = c.getCount();
for(int i = 0;i<count;++i){
c.moveToNext();
final Attachment attachment = new Attachment();
attachment.mFileName = c.getString(Attachment.CONTENT_FILENAME_COLUMN);
attachment.mContentUri = c.getString(Attachment.CONTENT_CONTENT_URI_COLUMN);
attachment.mSize = c.getLong(Attachment.CONTENT_SIZE_COLUMN);
attachment.mMimeType = c.getString(Attachment.CONTENT_MIME_TYPE_COLUMN);
if(attachment.mContentUri == null){
allAttachmentsDownload = false;
continue;
}
mHandler.post(new Runnable(){
public void run() {
addAttachment(attachment);
}
});
}
}finally {
c.close();
}
return allAttachmentsDownload;
}
private boolean loadAttachments(Message message,Context context){
return findAttachmentWithMessageId(context,message.mId);
}
在processSourceMessage()方法裏面:else if(ACTION_FORWARD.equals(mAction))下
if(!loadAttachments(message,MessageCompose.this)){
mHandler.sendEmaptyMessage(MSG_SKIPPED_ATTACHMENTS);
}這段代碼放開。
將MessagingController.java文件
loadAttachment方法裏面的:
pruneCachedAttachments(accountId);註銷掉
以上就是所修改的東西,改代碼經過測試,大家可以放心的使用,謝謝!!!