Skip to content

Commit

Permalink
fix getFileName error below api 11
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinea committed Jan 26, 2014
1 parent afc5b40 commit cb07285
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cn/trinea/android/common/util/DownloadManagerPro.java
Expand Up @@ -6,6 +6,7 @@
import android.app.DownloadManager.Request;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;

/**
* DownloadManagerPro
Expand Down Expand Up @@ -36,7 +37,10 @@
public class DownloadManagerPro {

public static final Uri CONTENT_URI = Uri.parse("content://downloads/my_downloads");
/** represents downloaded file above api 11 **/
public static final String COLUMN_LOCAL_FILENAME = "local_filename";
/** represents downloaded file below api 11 **/
public static final String COLUMN_LOCAL_URI = "local_uri";

public static final String METHOD_NAME_PAUSE_DOWNLOAD = "pauseDownload";
public static final String METHOD_NAME_RESUME_DOWNLOAD = "resumeDownload";
Expand Down Expand Up @@ -202,7 +206,7 @@ private static void initResumeMethod() {
* @return
*/
public String getFileName(long downloadId) {
return getString(downloadId, COLUMN_LOCAL_FILENAME);
return getString(downloadId, (Build.VERSION.SDK_INT < 11 ? COLUMN_LOCAL_URI : COLUMN_LOCAL_FILENAME));
}

/**
Expand Down

0 comments on commit cb07285

Please sign in to comment.