android email 邮件转发 附件不能转发问题的解决

最近碰到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);注销掉


以上就是所修改的东西,改代码经过测试,大家可以放心的使用,谢谢!!!


你可能感兴趣的:(c,android,测试,null,action,email)