diff options
Diffstat (limited to 'subsonic-android')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 98e86706..33c45a02 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -25,6 +25,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; +import java.util.concurrent.atomic.AtomicBoolean; import android.content.BroadcastReceiver; import android.content.Context; @@ -58,6 +59,7 @@ public class DownloadServiceLifecycleSupport { private PhoneStateListener phoneStateListener; private boolean externalStorageAvailable= true; private ReentrantLock lock = new ReentrantLock(); + private final AtomicBoolean setup = new AtomicBoolean(false); /** * This receiver manages the intent that could come from other applications. @@ -185,6 +187,10 @@ public class DownloadServiceLifecycleSupport { } public void serializeDownloadQueue() { + if(!setup.get()) { + return; + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { new SerializeTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { @@ -328,6 +334,7 @@ public class DownloadServiceLifecycleSupport { try { lock.lock(); deserializeDownloadQueueNow(); + setup.set(true); } finally { lock.unlock(); } |