From fd3b4c152a8bb6450ec31a559aea1e877a0b0629 Mon Sep 17 00:00:00 2001 From: Adrian Ulrich Date: Wed, 16 Sep 2015 19:48:54 +0200 Subject: [PATCH] Fix a crash bug due to mCurrentSong == null This happens if: * Notification is set to always * The user empties the queue This causes activeSongReplaced() to be called, so setCurrentSong(0); will be executed while mCurrentSong is already null. Updating the notification in this state crashes with a null pointer. However: The 'dangling' notification will have wrong information in this state - but it is still better than displaying an empty one as it just looks butt ugly. We whould probably, at some point, design an 'empty notification view' --- src/ch/blinkenlights/android/vanilla/PlaybackService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ch/blinkenlights/android/vanilla/PlaybackService.java b/src/ch/blinkenlights/android/vanilla/PlaybackService.java index 3a8d209d..b62e5f7d 100644 --- a/src/ch/blinkenlights/android/vanilla/PlaybackService.java +++ b/src/ch/blinkenlights/android/vanilla/PlaybackService.java @@ -976,7 +976,8 @@ public final class PlaybackService extends Service if (mNotificationMode == ALWAYS || mForceNotificationVisible) { stopForeground(false); - mNotificationManager.notify(NOTIFICATION_ID, createNotification(mCurrentSong, mState)); + if (mCurrentSong != null) + mNotificationManager.notify(NOTIFICATION_ID, createNotification(mCurrentSong, mState)); } else { stopForeground(true); }