diff options
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 93eefeeb..fa21f9f0 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -164,9 +164,22 @@ public class DownloadServiceLifecycleSupport { public void onStart(Intent intent) { if (intent != null && intent.getExtras() != null) { - KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT); + final KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT); if (event != null) { - handleKeyEvent(event); + new Thread(new Runnable(){ + @Override + public void run() { + try { + // Make sure everything is ready to go before handling event + if(!setup.get()) { + lock.lock(); + } + handleKeyEvent(event); + } finally { + lock.unlock(); + } + } + }); } } } |