parent
3311043e80
commit
8307015d8d
@ -294,6 +294,10 @@ public class AsyncDownloaderFromAndroid implements AsyncDownloader {
|
|||||||
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||||
DownloadManager.Query query = new DownloadManager.Query();
|
DownloadManager.Query query = new DownloadManager.Query();
|
||||||
Cursor c = dm.query(query);
|
Cursor c = dm.query(query);
|
||||||
|
if (c == null) {
|
||||||
|
// TODO: same as above.
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
int columnUniqueDownloadId = c.getColumnIndex(DownloadManager.COLUMN_DESCRIPTION);
|
int columnUniqueDownloadId = c.getColumnIndex(DownloadManager.COLUMN_DESCRIPTION);
|
||||||
int columnId = c.getColumnIndex(DownloadManager.COLUMN_ID);
|
int columnId = c.getColumnIndex(DownloadManager.COLUMN_ID);
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package org.fdroid.fdroid.net;
|
package org.fdroid.fdroid.net;
|
||||||
|
|
||||||
|
import android.app.DownloadManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
import org.fdroid.fdroid.Utils;
|
import org.fdroid.fdroid.Utils;
|
||||||
@ -75,7 +77,19 @@ public class DownloaderFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasDownloadManager(Context context) {
|
private static boolean hasDownloadManager(Context context) {
|
||||||
return context.getSystemService(Context.DOWNLOAD_SERVICE) != null;
|
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||||
|
if (dm == null) {
|
||||||
|
// Service was not found
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
DownloadManager.Query query = new DownloadManager.Query();
|
||||||
|
Cursor c = dm.query(query);
|
||||||
|
if (c == null) {
|
||||||
|
// Download Manager was disabled
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
c.close();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user