Search in sources :

Example 11 with MediaStyle

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();
}
Also used : MediaStyle(android.support.v4.media.app.NotificationCompat.MediaStyle) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PartyActivity(se.zinokader.spotiq.feature.party.PartyActivity) PendingIntent(android.app.PendingIntent)

Aggregations

NotificationCompat (android.support.v4.app.NotificationCompat)9 MediaStyle (android.support.v4.media.app.NotificationCompat.MediaStyle)9 PendingIntent (android.app.PendingIntent)7 Intent (android.content.Intent)6 Bitmap (android.graphics.Bitmap)5 Notification (android.app.Notification)2 NotificationManager (android.app.NotificationManager)2 Canvas (android.graphics.Canvas)2 Context (android.content.Context)1 SharedPreferences (android.content.SharedPreferences)1 Resources (android.content.res.Resources)1 DrawFilter (android.graphics.DrawFilter)1 Paint (android.graphics.Paint)1 PaintFlagsDrawFilter (android.graphics.PaintFlagsDrawFilter)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)1 MediaDescriptionCompat (android.support.v4.media.MediaDescriptionCompat)1 MediaMetadataCompat (android.support.v4.media.MediaMetadataCompat)1 MediaSessionCompat (android.support.v4.media.session.MediaSessionCompat)1