Adding attachment infomation to downloads database for it will appear in

Downloads App
This commit is contained in:
Swapnil Tailor 2015-12-30 22:18:11 -08:00
parent 52b28f91c4
commit ed2a7e3454

View file

@ -8,6 +8,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import android.app.DownloadManager;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
@ -17,6 +18,7 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
import android.util.Log;
import android.webkit.MimeTypeMap;
import android.widget.Toast;
import com.fsck.k9.Account;
@ -147,6 +149,8 @@ public class AttachmentController {
writeAttachmentToStorage(file);
addAttachmentToDownloadDatabase(file);
return file;
}
@ -165,6 +169,14 @@ public class AttachmentController {
}
}
/*
* Adding attachment information to Downloads database system, so it will appear in Downloads App
*/
private void addAttachmentToDownloadDatabase(File file) {
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
downloadManager.addCompletedDownload(file.getName(), file.getName(), true, attachment.mimeType, file.getAbsolutePath(), file.length(), true);
}
private Intent getBestViewIntentAndSaveFileIfNecessary() {
String displayName = attachment.displayName;
String inferredMimeType = MimeUtility.getMimeTypeByExtension(displayName);