Java Code Examples for android.support.v4.app.NotificationCompat#Style
The following examples show how to use
android.support.v4.app.NotificationCompat#Style .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlaybackNotificationFactoryImpl.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
@NonNull @Override public Notification create( @NonNull final Context context, @NonNull final Media media, @NonNull final PlaybackState state, @NonNull final MediaSessionCompat mediaSession) { ensureChannelExists(context); final Bitmap art = loadAlbumArt(context, media); final PendingIntent contentIntent = createContentIntent(context); final NotificationCompat.Style style = createNotificationStyle(mediaSession); final NotificationCompat.Builder b = new NotificationCompat.Builder(context, CHANNEL_ID) .setStyle(style) .setShowWhen(false) .setOnlyAlertOnce(true) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_SERVICE) .setContentTitle(media.getTitle()) .setContentText(media.getArtist()) .setContentIntent(contentIntent) .setAutoCancel(false) .setOngoing(true) .setSmallIcon(state == PlaybackState.STATE_PLAYING ? R.drawable.ic_stat_play : R.drawable.ic_stat_pause) .setLargeIcon(art); addAction1(context, b); addAction2(context, b, state); addAction3(context, b); return b.build(); }
Example 2
Source File: PlaybackNotificationFactoryImpl.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
@NonNull private static NotificationCompat.Style createNotificationStyle( @NonNull final MediaSessionCompat mediaSession) { return new android.support.v4.media.app.NotificationCompat.MediaStyle() .setMediaSession(mediaSession.getSessionToken()) .setShowActionsInCompactView(1, 2); }
Example 3
Source File: NotificationUtils.java From wear with MIT License | 5 votes |
private static void showNotificationWithStyle(Context context, int id, NotificationCompat.Style style) { NotificationManagerCompat.from(context).notify(id, new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_launcher) .setStyle(style) .build()); }
Example 4
Source File: HeadsUp.java From MoeQuest with Apache License 2.0 | 4 votes |
@Override public Builder setStyle(NotificationCompat.Style style) { super.setStyle(style); return this; }