Email forward attachment
时间:10-02
整理:3721RD
点击:
修改MessageCompose.java,请参考modifystarts/modifyends包围的代码。
1把附件Uri存放到Parcel中。FunctionstartActivityWithMessage
===================================
privatestaticvoidstartActivityWithMessage(Contextcontext,Stringaction,longmessageId){
Intenti=newIntent(context,MessageCompose.class);
i.putExtra(EXTRA_MESSAGE_ID,messageId);
//modifystarts
if(ACTION_FORWARD==action){//YoucanaddattachmentbyACTION_REPLY_ALLorACTION_REPLYhere.
finalAttachmentattachments[]=Attachment.restoreAttachmentsWithMessageId(context,messageId);
if(null!=attachments){
finalArrayListuris=newArrayList();
for(Attachmentattachment:attachments){
if(null!=attachment.mContentUri){
finalUriuri=Uri.parse(attachment.mContentUri);
if(null!=uri){
uris.add(uri);
}
}
}
i.putParcelableArrayListExtra(Intent.EXTRA_STREAM,uris);
//i.setType(""application/octet-stream"");
}
}
//modifyends
i.setAction(action);
context.startActivity(i);
}
===================================
2,在调起composeactivity时,把附件信息加入邮件中。
FunctiononCreate
===================================
//Handlethevariousintentsthatlaunchthemessagecomposer
if(Intent.ACTION_VIEW.equals(mAction)
||Intent.ACTION_SENDTO.equals(mAction)
||Intent.ACTION_SEND.equals(mAction)
||Intent.ACTION_SEND_MULTIPLE.equals(mAction)){
setAccount(intent);
//UsethefieldsfoundintheIntenttoprefillasmuchofthemessageaspossible
initFROMIntent(intent);
setDraftNeedsSaving(true);
mMessageLoaded=true;
mSourceMessageProcessed=true;
}else{
//Otherwise,handletheinternalcases(MessageComposerinvokedfromwithinapp)
longmessageId=draftId!=-1?draftId:intent.getLongExtra(EXTRA_MESSAGE_ID,-1);
if(messageId!=-1){
mLoadMessageTask=newLoadMessageTask().execute(messageId);
//modifystarts
Stringtype=intent.getType();
if(null==type){
type=Email.ACCEPTABLE_ATTACHMENT_SEND_INTENT_TYPES[0];
}
finalArrayListuris=intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
if(null!=uris){
finalinturiCount=uris.size();
for(int count=0; count<uriCount; count++){
finalUristream=(Uri)uris.get(count);
if(stream!=null&&type!=null){
if(MimeUtility.mimeTypeMatches(type,Email.ACCEPTABLE_ATTACHMENT_SEND_INTENT_TYPES)){
addAttachment(stream);
}
}
}
}
//modifyends
}else{
setAccount(intent);
//Sincethisisanewmessage,wedon'tneedtocallLoadMessageTask.
//ButweDOneedtosetmMessageLoadedtoindicatethemessagecanbesent
mMessageLoaded=true;
mSourceMessageProcessed=true;
}
setInitialComposeText(null,(mAccount!=null)?mAccount.mSignature:null);
}
if(ACTION_REPLY.equals(mAction)||ACTION_REPLY_ALL.equals(mAction)||
ACTION_FORWARD.equals(mAction)||ACTION_EDIT_DRAFT.equals(mAction)){
===================================