diff --git a/ThinDownloadManager/build.gradle b/ThinDownloadManager/build.gradle index 47db80b..f987464 100644 --- a/ThinDownloadManager/build.gradle +++ b/ThinDownloadManager/build.gradle @@ -13,7 +13,7 @@ android { buildToolsVersion "26.0.2" defaultConfig { - minSdkVersion 9 + minSdkVersion 16 targetSdkVersion 26 versionCode 1 versionName "1" diff --git a/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadDispatcher.java b/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadDispatcher.java index a6ff0bc..6257219 100644 --- a/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadDispatcher.java +++ b/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadDispatcher.java @@ -1,5 +1,6 @@ package com.thin.downloadmanager; +import android.content.Intent; import android.os.Process; import com.thin.downloadmanager.util.Log; @@ -172,6 +173,9 @@ private void executeDownload(DownloadRequest request, String downloadUrl) { Log.d(TAG, "Existing mDownloadedCacheSize: " + mDownloadedCacheSize); Log.d(TAG, "File mContentLength: " + mContentLength); if (mDownloadedCacheSize == mContentLength) { // Mark as success, If end of stream already reached + if (request.getMimeType() == null) { + request.setMimeType(Intent.normalizeMimeType(conn.getContentType())); + } updateDownloadComplete(request); Log.d(TAG, "Download Completed"); } else { @@ -236,6 +240,9 @@ private void transferData(DownloadRequest request, HttpURLConnection conn) { try { try { in = new BufferedInputStream(conn.getInputStream()); + if (request.getMimeType() == null) { + request.setMimeType(Intent.normalizeMimeType(conn.getContentType())); + } } catch (IOException e) { e.printStackTrace(); } diff --git a/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequest.java b/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequest.java index 32b8db9..776fafe 100644 --- a/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequest.java +++ b/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequest.java @@ -64,6 +64,8 @@ public enum Priority { private DownloadStatusListenerV1 mDownloadStatusListenerV1; + private String mMimeType; + private Object mDownloadContext; private HashMap mCustomHeader; @@ -260,7 +262,13 @@ public boolean isCancelled() { return mCancelled; } + public String getMimeType() { + return mMimeType; + } + public void setMimeType(String mMimeType) { + this.mMimeType = mMimeType; + } /** * Marked the request as canceled is aborted. diff --git a/ThinDownloadManagerTestApp/build.gradle b/ThinDownloadManagerTestApp/build.gradle index 0cca09e..3b2df83 100644 --- a/ThinDownloadManagerTestApp/build.gradle +++ b/ThinDownloadManagerTestApp/build.gradle @@ -6,7 +6,7 @@ android { defaultConfig { applicationId "com.mani.thindownloadmanager.app" - minSdkVersion 9 + minSdkVersion 16 targetSdkVersion 26 versionCode 1 versionName "1.0"