use of android.support.v4.media.app.NotificationCompat.MediaStyle in project SpotiQ by ZinoKader.
the class NotificationUtil method buildPlayerNotificationCompat.
public static Notification buildPlayerNotificationCompat(Context context, MediaSessionCompat mediaSessionCompat, String title, String description, Bitmap largeIcon) {
PendingIntent openPartyIntent = PendingIntent.getActivity(context, 0, new Intent(context, PartyActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
Intent playPauseActionIntent = new Intent(context, SpotiqHostService.class);
playPauseActionIntent.setAction(ServiceConstants.ACTION_PLAY_PAUSE);
PendingIntent playPauseIntent = PendingIntent.getService(context, 1, playPauseActionIntent, PendingIntent.FLAG_UPDATE_CURRENT);
int largeIconWidth = context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width);
int largeIconHeight = context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height);
largeIcon = Bitmap.createScaledBitmap(largeIcon, largeIconWidth, largeIconHeight, false);
return new NotificationCompat.Builder(context, ApplicationConstants.MEDIA_NOTIFICATION_CHANNEL_ID).setSmallIcon(R.drawable.ic_notification_logo).setLargeIcon(largeIcon).addAction(new NotificationCompat.Action(R.drawable.ic_notification_play_pause, "Play/Pause", playPauseIntent)).setStyle(new MediaStyle().setMediaSession(mediaSessionCompat.getSessionToken()).setShowActionsInCompactView(0)).setColorized(true).setContentTitle(title).setContentText(description).setContentIntent(openPartyIntent).setOngoing(true).setDefaults(4).build();
}
Aggregations