notification does not show when expected
Instead, the notification shows up after you have paused it, presumably because showNotification() is placed in onPlayerStateChanged().
Then the notification disappears after completing a question. It will only reappear after pressing pause again in the next question. This behaviour probably occurs because the activity is finished and recreated with each next question.
Not sure where showNotification() should be placed instead to address these issues.
Did you find a fix for this? I can't seem to see notification when playing or paused .
Keep Coding : - )
I call showMediaNotification() after mMediaSession.setPlaybackState() inside initMediaSession() to fix this.
But this is not the only problem with notifications. Notification re-appears after cancelled when returning to main activity, because mNotificationManager.cancelAll() must be called AFTER stopPlayer() completes. Otherwise we cancel notification, then call player.stop and this causes state change along with new notification.
Additionally, I had to call initMediaSession() from within initializePlayer() jsut BEFORE mPlayer.addListener() because sometimes callback was called when no mMediaSession or mStateBuilder was created causing crash.