Buggy code:
List < EnhancedMediaPlayer > getPlaylist ( ) { } private DaoSession dbSounds ; private synchronized MediaPlayerDataDao getSoundsDao ( ) { } private Map < String , List < EnhancedMediaPlayer > > sounds = new HashMap < > ( ) ; Map < String , List < EnhancedMediaPlayer > > getSounds ( ) { } private LocalBroadcastManager broadcastManager ; private BroadcastReceiver soundStateChangedReceiver ; private BroadcastReceiver notificationActionReceiver ; private MusicService . Binder binder ; private NotificationManager notificationManager ; private List < PendingSoundNotification > notifications ; @ Override public IBinder onBind ( Intent intent ) { } @ Override public void onCreate ( ) { } @ Override public void onDestroy ( ) { } @ Override public int onStartCommand ( Intent intent , int flags , int startId ) { } public void onActivityResumed ( ) { } public void onActivityClosed ( ) { } private PendingSoundNotificationBuilder getNotificationForSound ( EnhancedMediaPlayer player ) { } private PendingSoundNotificationBuilder getNotificationForPlaylist ( EnhancedMediaPlayer player ) { } private void addNotification ( PendingSoundNotificationBuilder notificationBuilder ) { } public void storeLoadedSounds ( ) { } public List < EnhancedMediaPlayer > getCurrentlyPlayingSounds ( ) { } private List < EnhancedMediaPlayer > getPlayingSoundsFromSoundList ( ) { } private EnhancedMediaPlayer getPlayingSoundFromPlaylist ( ) { } public void addNewSoundToServiceAndDatabase ( MediaPlayerData playerData ) { } private void addSoundToSounds ( EnhancedMediaPlayer player ) { } private EnhancedMediaPlayer createSoundFromRawData ( MediaPlayerData playerData ) { } public void addNewSoundToPlaylist ( MediaPlayerData playerData ) { } private MediaPlayerData createPlaylistSoundFromPlayerData ( MediaPlayerData playerData ) { } public void removeSounds ( String fragmentTag ) { } public void removeSounds ( List < EnhancedMediaPlayer > soundsToRemove ) { } public void removeFromPlaylist ( List < EnhancedMediaPlayer > playersToRemove ) { } public void toggleSoundInPlaylist ( String playerId , boolean addToPlayList ) { } private void destroyPlayerAndUpdateDatabase ( MediaPlayerDataDao dao , EnhancedMediaPlayer player ) { } private void removeSoundFromDatabase ( MediaPlayerDataDao dao , MediaPlayerData playerData ) { } private EnhancedMediaPlayer searchInSoundsAndPlaylistForId ( String playerId ) { } private EnhancedMediaPlayer searchInPlaylistForId ( String playerId ) { } private EnhancedMediaPlayer searchInSoundsForId ( String playerId ) { } private EnhancedMediaPlayer searchInListForId ( String playerId , List < EnhancedMediaPlayer > players ) { } public void moveSoundInFragment ( String fragmentTag , int from , int to ) { } private class LoadSoundsTask extends MusicService . LoadTask < MediaPlayerData > { @ Override public List < MediaPlayerData > call ( ) throws Exception { } @ Override protected void onSuccess ( List < MediaPlayerData > mediaPlayersData ) throws Exception { } private void sendBroadcastLoadingSoundsSuccessful ( ) { } } private class LoadPlaylistTask extends MusicService . LoadTask < MediaPlayerData > { @ Override public List < MediaPlayerData > call ( ) throws Exception { } @ Override protected void onSuccess ( List < MediaPlayerData > mediaPlayersData ) throws Exception { } private void sendBroadcastLoadingPlayListSuccessful ( ) { } } private abstract class LoadTask < T > extends SafeAsyncTask < List < T > > { @ Override protected void onSuccess ( List < T > ts ) throws Exception { } @ Override protected void onException ( Exception e ) throws RuntimeException { } } private class UpdateSoundsTask extends SafeAsyncTask < Void > { private List < MediaPlayerData > mediaPlayers ; private DaoSession database ; private MediaPlayerDataDao dao ; public UpdateSoundsTask ( Map < String , List < EnhancedMediaPlayer > > mediaPlayers , DaoSession database ) { } public UpdateSoundsTask ( List < EnhancedMediaPlayer > mediaPlayers , DaoSession database ) { } @ Override public Void call ( ) throws Exception { } private void updateStorePlayerData ( MediaPlayerData storedPlayer , MediaPlayerData newPlayerData ) { } @ Override protected void onException ( Exception e ) throws RuntimeException { } } public class Binder extends android . os . Binder { public MusicService getService ( ) { } } private class SoundStateChangeReceiver extends BroadcastReceiver { @ Override public void onReceive ( Context context , Intent intent ) { Logger . d ( MusicService . TAG , ( "SoundStateChangeReceiver.onReceive<seq2seq4repair_space>" + intent ) ) ; String action = intent . getAction ( ) ; String playerId = intent . getStringExtra ( KEY_PLAYER_ID ) ; if ( ( action == null ) || ( playerId == null ) ) return ; EnhancedMediaPlayer player = searchInPlaylistForId ( playerId ) ; if ( player != null ) { boolean isPendingNotification = this . updatePendingPlaylistNotification ( ) ; if ( ! isPendingNotification ) addNotification ( getNotificationForPlaylist ( player ) ) ; } else { boolean isPendingNotification = this . updatePendingNotification ( playerId ) ; <START_BUG> if ( isPendingNotification ) <END_BUG> addNotification ( getNotificationForSound ( searchInSoundsForId ( playerId ) ) ) ; } } private boolean updatePendingPlaylistNotification ( ) { } private boolean updatePendingNotification ( String playerId ) { } private PendingSoundNotification findNotificationForPendingPlayer ( String playerId ) { } private PendingSoundNotification findNotificationById ( int notificationId ) { } } private class NotificationActionReceiver extends BroadcastReceiver { @ Override public void onReceive ( Context context , Intent intent ) { Logger . d ( MusicService . TAG , ( "NotificationActionReceiver.onReceive<seq2seq4repair_space>" + intent ) ) ; String action = intent . getAction ( ) ; if ( action == null ) return ; String playerId = intent . getStringExtra ( KEY_PLAYER_ID ) ; if ( playerId == null ) return ; if ( action . equals ( ACTION_DISMISS ) ) { int notificationId = intent . getIntExtra ( KEY_NOTIFICATION_ID , 0 ) ; this . dismissPendingMediaPlayer ( notificationId , playerId ) ; } else { EnhancedMediaPlayer player = searchInSoundsAndPlaylistForId ( playerId ) ; switch ( action ) { case Constants . ACTION_PAUSE : player . pauseSound ( ) ; break ; case Constants . ACTION_STOP : player . stopSound ( ) ; break ; case Constants . ACTION_PLAY : player . playSound ( ) ; break ; } } } private void dismissPendingMediaPlayer ( int notificationId , String playerId ) { } private void stopAllSoundsInPlaylist ( ) { } private void stopSound ( String playerId ) { } } }

Fix:
if ( ! isPendingNotification )