From c2054be4600cd88155d12be01e166ba38ff0d32c Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Sat, 16 Jun 2012 13:31:28 +0200 Subject: [PATCH] Removed unnecessary communication with DownloadService --- src/de/podfetcher/service/DownloadService.java | 8 ++++++++ src/de/podfetcher/storage/DownloadRequester.java | 5 ++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/de/podfetcher/service/DownloadService.java b/src/de/podfetcher/service/DownloadService.java index cafdeecab..36b894242 100644 --- a/src/de/podfetcher/service/DownloadService.java +++ b/src/de/podfetcher/service/DownloadService.java @@ -63,6 +63,14 @@ public class DownloadService extends Service { } } + + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + queryDownloads(); + return super.onStartCommand(intent, flags, startId); + } + @Override public void onCreate() { Log.d(TAG, "Service started"); diff --git a/src/de/podfetcher/storage/DownloadRequester.java b/src/de/podfetcher/storage/DownloadRequester.java index 52bb663e8..a92b3a0e7 100644 --- a/src/de/podfetcher/storage/DownloadRequester.java +++ b/src/de/podfetcher/storage/DownloadRequester.java @@ -76,12 +76,11 @@ public class DownloadRequester { // TODO Set Allowed Network Types DownloadManager manager = (DownloadManager) context .getSystemService(Context.DOWNLOAD_SERVICE); - context.startService(new Intent(context, DownloadService.class)); + long downloadId = manager.enqueue(request); item.setDownloadId(downloadId); item.setFile_url(dest.toString()); - - notifyDownloadService(context); + context.startService(new Intent(context, DownloadService.class)); return downloadId; }