I have the following code:
private Notification ongoingNotification() {
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(getApplicationContext(), PlayerUI.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
String title = "meuplayer";
String msg = "Tocando. Clique para abrir.";
if (currentStreamBeingPlayed != null) {
msg = currentStreamBeingPlayed.getTitle();
}
PendingIntent previousSongPendingIntent = createPendingIntent(PlayerService.PREVIOUS_SONG);
PendingIntent pausePendingIntent = createPendingIntent(PlayerService.PAUSE);
PendingIntent nextSongPendingIntent = createPendingIntent(PlayerService.NEXT_SONG);
PendingIntent playPendingIntent = createPendingIntent(PlayerService.PLAY);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.mipmap.ic_notification)
.setContentTitle(title)
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg)
.addAction(R.mipmap.ic_prev, "", previousSongPendingIntent);
if (!mediaPlayer.isPlaying()) {
mBuilder.addAction(R.mipmap.ic_play, "", playPendingIntent);
} else {
mBuilder.addAction(R.mipmap.ic_pause, "", pausePendingIntent);
}
mBuilder.addAction(R.mipmap.ic_next, "", nextSongPendingIntent)
.setOngoing(true);
if (currentStreamBeingPlayed != null && currentStreamBeingPlayed.getPicture() != null) {
try {
URL urlPicture = new URL(currentStreamBeingPlayed.getPicture());
Bitmap largeIcon = ImageHandler.decodeURLstreamToBitmap(urlPicture, getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width), getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height));
mBuilder.setLargeIcon(largeIcon);
} catch (MalformedURLException e) {
} catch (Resources.NotFoundException e) {
} catch (IOException e) {
}
}
mBuilder.setContentIntent(contentIntent);
return mBuilder.build();
}
How can I make the image within the notification to update along with the music (if paused or play)? because it is not upgraded as the music runs