From 3f3f850ea8328d5846d0e3ae8f600e8068f20ba6 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 1 Oct 2016 21:05:35 -0700 Subject: Workaround for #739 --- .../github/daneren2005/dsub/util/Notifications.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java index 0d4a0f9c..d6a92b07 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java @@ -99,7 +99,12 @@ public final class Notifications { public void run() { downloadService.stopForeground(true); showDownloadingNotification(context, downloadService, handler, downloadService.getCurrentDownloading(), downloadService.getBackgroundDownloads().size()); - downloadService.startForeground(NOTIFICATION_ID_PLAYING, notification); + + try { + downloadService.startForeground(NOTIFICATION_ID_PLAYING, notification); + } catch(Exception e) { + Log.e(TAG, "Failed to start notifications after stopping foreground download"); + } } }); } else { @@ -107,13 +112,22 @@ public final class Notifications { @Override public void run() { if (playing) { - downloadService.startForeground(NOTIFICATION_ID_PLAYING, notification); + try { + downloadService.startForeground(NOTIFICATION_ID_PLAYING, notification); + } catch(Exception e) { + Log.e(TAG, "Failed to start notifications while playing"); + } } else { playShowing = false; persistentPlayingShowing = true; NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); downloadService.stopForeground(false); - notificationManager.notify(NOTIFICATION_ID_PLAYING, notification); + + try { + notificationManager.notify(NOTIFICATION_ID_PLAYING, notification); + } catch(Exception e) { + Log.e(TAG, "Failed to start notifications while paused"); + } } } }); -- cgit v1.2.3