List of usage examples for android.support.v4.media MediaDescriptionCompat getTitle
@Nullable
public CharSequence getTitle()
From source file:com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector.java
private void updateMediaSessionMetadata() { if (doMaintainMetadata) { MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder(); if (player != null && player.isPlayingAd()) { builder.putLong(MediaMetadataCompat.METADATA_KEY_ADVERTISEMENT, 1); }//from w w w . j av a2 s.c o m builder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, player == null ? 0 : player.getDuration() == C.TIME_UNSET ? -1 : player.getDuration()); if (queueNavigator != null) { long activeQueueItemId = queueNavigator.getActiveQueueItemId(player); List<MediaSessionCompat.QueueItem> queue = mediaController.getQueue(); for (int i = 0; queue != null && i < queue.size(); i++) { MediaSessionCompat.QueueItem queueItem = queue.get(i); if (queueItem.getQueueId() == activeQueueItemId) { MediaDescriptionCompat description = queueItem.getDescription(); if (description.getTitle() != null) { builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, String.valueOf(description.getTitle())); } if (description.getSubtitle() != null) { builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, String.valueOf(description.getSubtitle())); } if (description.getDescription() != null) { builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION, String.valueOf(description.getDescription())); } if (description.getIconBitmap() != null) { builder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, description.getIconBitmap()); } if (description.getIconUri() != null) { builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI, String.valueOf(description.getIconUri())); } if (description.getMediaId() != null) { builder.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, String.valueOf(description.getMediaId())); } if (description.getMediaUri() != null) { builder.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI, String.valueOf(description.getMediaUri())); } break; } } } mediaSession.setMetadata(builder.build()); } }
From source file:com.bayapps.android.robophish.ui.tv.CardPresenter.java
@Override public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) { MediaDescriptionCompat description; if (item instanceof MediaBrowserCompat.MediaItem) { MediaBrowserCompat.MediaItem mediaItem = (MediaBrowserCompat.MediaItem) item; LogHelper.d(TAG, "onBindViewHolder MediaItem: ", mediaItem.toString()); description = mediaItem.getDescription(); } else if (item instanceof MediaSessionCompat.QueueItem) { MediaSessionCompat.QueueItem queueItem = (MediaSessionCompat.QueueItem) item; description = queueItem.getDescription(); } else {/* ww w. j av a 2 s .c om*/ throw new IllegalArgumentException( "Object must be MediaItem or QueueItem, not " + item.getClass().getSimpleName()); } final CardViewHolder cardViewHolder = (CardViewHolder) viewHolder; cardViewHolder.mCardView.setTitleText(description.getTitle()); cardViewHolder.mCardView.setContentText(description.getSubtitle()); cardViewHolder.mCardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT); Uri artUri = description.getIconUri(); if (artUri == null) { setCardImage(cardViewHolder, description.getIconBitmap()); } else { // IconUri potentially has a better resolution than iconBitmap. String artUrl = artUri.toString(); AlbumArtCache cache = AlbumArtCache.getInstance(); if (cache.getBigImage(artUrl) != null) { // So, we use it immediately if it's cached: setCardImage(cardViewHolder, cache.getBigImage(artUrl)); } else { // Otherwise, we use iconBitmap if available while we wait for iconURI setCardImage(cardViewHolder, description.getIconBitmap()); cache.fetch(artUrl, new AlbumArtCache.FetchListener() { @Override public void onFetched(String artUrl, Bitmap bitmap, Bitmap icon) { setCardImage(cardViewHolder, bitmap); } }); } } }
From source file:com.murati.oszk.audiobook.ui.MediaItemViewHolder.java
static View setupListView(final Activity activity, View convertView, final ViewGroup parent, MediaBrowserCompat.MediaItem item) { if (sColorStateNotPlaying == null || sColorStatePlaying == null) initializeColorStateLists(activity); // Create holder and cache-state MediaDescriptionCompat description = item.getDescription(); final MediaItemViewHolder holder; Integer cachedState = STATE_INVALID; // Inflate new holder for the basic types: holder = new MediaItemViewHolder(); //TODO: optimize inflators if (MediaIDHelper.isItemHeader(description.getMediaId())) { // EBook header convertView = LayoutInflater.from(activity).inflate(R.layout.fragment_list_header, parent, false); } else if (MediaIDHelper.isEBookHeader(description.getMediaId())) { // EBook header convertView = LayoutInflater.from(activity).inflate(R.layout.fragment_ebook_header, parent, false); } else if (MediaIDHelper.isBrowseable(description.getMediaId()) && (MediaIDHelper.isEBook(description.getMediaId())) || MediaIDHelper.MEDIA_ID_BY_QUEUE.equals(description.getMediaId())) { // EBOOK Card // It is an e-book, so let's inflate with the e-book template convertView = LayoutInflater.from(activity).inflate(R.layout.fragment_ebook_item, parent, false); } else {// w w w . ja v a 2 s. c o m // Everything else convertView = LayoutInflater.from(activity).inflate(R.layout.fragment_list_item, parent, false); } convertView.setTag(holder); //Lookup the standard fields holder.mImageView = (ImageView) convertView.findViewById(R.id.play_eq); holder.mTitleView = (TextView) convertView.findViewById(R.id.title); holder.mDescriptionView = (TextView) convertView.findViewById(R.id.description); // Set values if (holder.mTitleView != null) { holder.mTitleView.setText(description.getTitle()); } if (holder.mDescriptionView != null) { holder.mDescriptionView.setText(description.getSubtitle()); } // Load images if (holder.mImageView != null) { // If the state of convertView is different, we need to adapt it int state = getMediaItemState(activity, item); if (cachedState == null || cachedState != state) { // Split case by browsable or by playable if (MediaIDHelper.isBrowseable(description.getMediaId()) || MediaIDHelper.isEBookHeader(description.getMediaId())) { // Browsable container represented by its image Uri imageUri = item.getDescription().getIconUri(); GlideApp.with(activity).load(imageUri).override(Target.SIZE_ORIGINAL) .fallback(R.drawable.default_book_cover).error(R.drawable.default_book_cover). /*listener(new RequestListener<Drawable>() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { return false; } }).*/ into(holder.mImageView); // In addition to being browsable add quick-controls too if (MediaIDHelper.isEBook(description.getMediaId())) { holder.mDownloadButton = (Button) convertView.findViewById(R.id.card_download); if (holder.mDownloadButton != null) { holder.mDownloadButton.setTag(description.getMediaId()); holder.mDownloadButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { OfflineBookService.downloadWithActivity((String) v.getTag(), activity); } }); } holder.mFavoriteButton = (ImageView) convertView.findViewById(R.id.card_favorite); if (holder.mFavoriteButton != null) { holder.mFavoriteButton .setImageResource(FavoritesHelper.getFavoriteIcon(description.getMediaId())); holder.mFavoriteButton.setTag(description.getMediaId()); holder.mFavoriteButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { ((ImageView) v).setImageResource( FavoritesHelper.toggleFavoriteWithText((String) v.getTag(), activity)); } }); } //holder.mOpenButton = (Button) convertView.findViewById(R.id.card_open); if (holder.mOpenButton != null) { //TODO: solve event listener } } } else { // Playable item represented by its state Drawable drawable = getDrawableByState(activity, state); if (drawable != null) holder.mImageView.setImageDrawable(drawable); //holder.mImageView.setImageTintMode(PorterDuff.Mode.SRC_IN); //If offline and not available /*if (!NetworkHelper.isOnline(parent.getContext())) { String source = OfflineBookService.getTrackSource( MusicProvider.getTrack(description.getMediaId())); holder.mTitleView.setTextColor(Color.CYAN); }*/ } holder.mImageView.setVisibility(View.VISIBLE); convertView.setTag(R.id.tag_mediaitem_state_cache, state); } } return convertView; }
From source file:org.amahi.anywhere.util.MediaNotificationManager.java
private Notification createNotification() { Log.d(TAG, "updateNotificationMetadata. mMetadata=" + mMetadata); if (mMetadata == null || mPlaybackState == null) { return null; }/*from ww w. j a v a 2s .c o m*/ NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mService); notificationBuilder.addAction(android.R.drawable.ic_media_previous, mService.getString(R.string.label_previous), mPreviousIntent); addPlayPauseAction(notificationBuilder); notificationBuilder.addAction(android.R.drawable.ic_media_next, mService.getString(R.string.label_next), mNextIntent); MediaDescriptionCompat description = mMetadata.getDescription(); Bitmap audioAlbumArt = mMetadata.getBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART); if (audioAlbumArt == null) { // use a placeholder art while the remote art is being downloaded audioAlbumArt = BitmapFactory.decodeResource(mService.getResources(), R.drawable.default_audiotrack); } notificationBuilder.setStyle(new NotificationCompat.MediaStyle().setShowActionsInCompactView(1) // show only play/pause in compact view .setMediaSession(mSessionToken)).setSmallIcon(getAudioPlayerNotificationIcon()) .setLargeIcon(getAudioPlayerNotificationArtwork(audioAlbumArt)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setContentIntent(mService.createContentIntent()).setContentTitle(description.getTitle()) .setContentText(description.getSubtitle()) .setOngoing(mPlaybackState.getState() == PlaybackStateCompat.STATE_PLAYING); // setNotificationPlaybackState(notificationBuilder); return notificationBuilder.build(); }
From source file:org.runbuddy.tomahawk.utils.MediaNotification.java
private void updateNotificationMetadata() { Log.d(TAG, "updateNotificationMetadata. mMetadata=" + mMetadata); if (mMetadata == null || mPlaybackState == null) { return;/*from w w w . j a v a 2s . co m*/ } mNotificationBuilder = new NotificationCompat.Builder(mService); List<Integer> showInCompact = new ArrayList<>(); updateFavoriteAction(); showInCompact.add(mNotificationBuilder.mActions.size()); mNotificationBuilder.addAction(mFavoriteAction); // If skip to previous action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) { NotificationCompat.Action action = new NotificationCompat.Action.Builder( R.drawable.ic_player_previous_light, mService.getString(R.string.playback_previous), mIntents.get(R.drawable.ic_player_previous_light)).build(); mNotificationBuilder.addAction(action); } updatePlayPauseAction(); showInCompact.add(mNotificationBuilder.mActions.size()); mNotificationBuilder.addAction(mPlayPauseAction); // If skip to next action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) { NotificationCompat.Action action = new NotificationCompat.Action.Builder( R.drawable.ic_player_next_light, mService.getString(R.string.playback_next), mIntents.get(R.drawable.ic_player_next_light)).build(); showInCompact.add(mNotificationBuilder.mActions.size()); mNotificationBuilder.addAction(action); } MediaDescriptionCompat description = mMetadata.getDescription(); Bitmap art = description.getIconBitmap(); if (art == null) { // use a placeholder art while the remote art is being downloaded art = BitmapFactory.decodeResource(mService.getResources(), R.drawable.album_placeholder); } mNotificationBuilder .setStyle(new NotificationCompat.MediaStyle() .setShowActionsInCompactView(ArrayUtil.toIntArray(showInCompact)) .setMediaSession(mSessionToken).setShowCancelButton(true)) .setColor(mNotificationColor).setSmallIcon(R.drawable.ic_notification) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setContentIntent(createContentIntent()) .setContentTitle(description.getTitle()).setContentText(description.getSubtitle()) .setTicker(description.getTitle() + " - " + description.getSubtitle()).setLargeIcon(art) .setOngoing(false); updateNotificationPlaybackState(); mService.startForeground(NOTIFICATION_ID, mNotificationBuilder.build()); Log.d(TAG, "updateNotificationMetadata. Notification shown"); }
From source file:com.example.android.supportv4.media.MediaNotificationManager.java
private Notification createNotification() { Log.d(TAG, "updateNotificationMetadata. mMetadata=" + mMetadata); if (mMetadata == null || mPlaybackState == null) { return null; }/*from w w w. jav a 2 s.co m*/ NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mService); // If skip to previous action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) { notificationBuilder.addAction(R.drawable.ic_skip_previous_white_24dp, mService.getString(R.string.label_previous), mPreviousIntent); } addPlayPauseAction(notificationBuilder); // If skip to next action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) { notificationBuilder.addAction(R.drawable.ic_skip_next_white_24dp, mService.getString(R.string.label_next), mNextIntent); } MediaDescriptionCompat description = mMetadata.getDescription(); String fetchArtUrl = null; Bitmap art = null; if (description.getIconUri() != null) { // This sample assumes the iconUri will be a valid URL formatted String, but // it can actually be any valid Android Uri formatted String. // async fetch the album art icon String artUrl = description.getIconUri().toString(); art = AlbumArtCache.getInstance().getBigImage(artUrl); if (art == null) { fetchArtUrl = artUrl; // use a placeholder art while the remote art is being downloaded art = BitmapFactory.decodeResource(mService.getResources(), R.drawable.ic_default_art); } } notificationBuilder.setColor(mNotificationColor).setSmallIcon(R.drawable.ic_notification) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setUsesChronometer(true) .setContentIntent(createContentIntent()).setContentTitle(description.getTitle()) .setContentText(description.getSubtitle()).setLargeIcon(art); setNotificationPlaybackState(notificationBuilder); if (fetchArtUrl != null) { fetchBitmapFromURLAsync(fetchArtUrl, notificationBuilder); } return notificationBuilder.build(); }
From source file:com.classiqo.nativeandroid_32bitz.MediaNotificationManager.java
private Notification createNotification() { LogHelper.d(TAG, "updateNotificationMetadata.mMetadata = " + mMetadata); if (mMetadata == null || mPlaybackState == null) { return null; }/*from w ww.j a va 2 s .c om*/ NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mService); int playPauseButtonPosition = 0; if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) { notificationBuilder.addAction(R.drawable.ic_skip_previous_white_24dp, mService.getString(R.string.label_previous), mPreviousIntent); playPauseButtonPosition = 1; } addPlayPauseAction(notificationBuilder); if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) { notificationBuilder.addAction(R.drawable.ic_skip_next_white_24dp, mService.getString(R.string.label_next), mNextIntent); } MediaDescriptionCompat description = mMetadata.getDescription(); String fetchArtUrl = null; Bitmap art = null; if (description.getIconUri() != null) { String artUrl = description.getIconUri().toString(); art = AlbumArtCache.getInstance().getBigImage(artUrl); if (art == null) { fetchArtUrl = artUrl; art = BitmapFactory.decodeResource(mService.getResources(), R.drawable.ic_default_art); } } notificationBuilder .setStyle(new NotificationCompat.MediaStyle() .setShowActionsInCompactView(new int[] { playPauseButtonPosition }) .setMediaSession(mSessionToken)) .setColor(mNotificationColor).setSmallIcon(R.drawable.ic_notification) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setUsesChronometer(true) .setContentIntent(createContentIntent(description)).setContentTitle(description.getTitle()) .setContentText(description.getSubtitle()).setLargeIcon(art); if (mController != null && mController.getExtras() != null) { String castName = mController.getExtras().getString(MusicService.EXTRA_CONNECTED_CAST); if (castName != null) { String castInfo = mService.getResources().getString(R.string.casting_to_device, castName); notificationBuilder.setSubText(castInfo); notificationBuilder.addAction(R.drawable.ic_close_black_24dp, mService.getString(R.string.stop_casting), mStopCastIntent); } } setNotificationPlaybackState(notificationBuilder); if (fetchArtUrl != null) { fetchBitmapFromURLAsync(fetchArtUrl, notificationBuilder); } return notificationBuilder.build(); }
From source file:nuclei.media.MediaNotificationManager.java
Notification createNotification() { LOG.d("updateNotificationMetadata. mMetadata=", mMetadata); if (mMetadata == null || mPlaybackState == null) { return null; }//from ww w . j a v a 2 s . co m NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mService); int playPauseButtonPosition = 0; // If skip to previous action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) { notificationBuilder.addAction(ResourceProvider.getInstance().getDrawable(ResourceProvider.PREVIOUS), ResourceProvider.getInstance().getString(ResourceProvider.PREVIOUS), mPreviousIntent); // If there is a "skip to previous" button, the play/pause button will // be the second one. We need to keep track of it, because the MediaStyle notification // requires to specify the index of the buttons (actions) that should be visible // when in compact view. playPauseButtonPosition = 1; } addPlayPauseAction(notificationBuilder); // If skip to next action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) { notificationBuilder.addAction(ResourceProvider.getInstance().getDrawable(ResourceProvider.NEXT), ResourceProvider.getInstance().getString(ResourceProvider.NEXT), mNextIntent); } MediaDescriptionCompat description = mMetadata.getDescription(); Bitmap bitmap = description.getIconBitmap(); if (bitmap != null && bitmap.isRecycled()) bitmap = null; if (bitmap == null) { bitmap = mMetadata.getBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { notificationBuilder .setStyle( new NotificationCompat.MediaStyle().setShowActionsInCompactView(playPauseButtonPosition) // show only play/pause in compact view .setShowCancelButton(true).setCancelButtonIntent(mCancelIntent) .setMediaSession(mSessionToken)) .setContentIntent(createContentIntent(description)); } notificationBuilder.setColor(mNotificationColor).setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setUsesChronometer(true).setContentTitle(description.getTitle()) .setContentText(description.getSubtitle()) .setSmallIcon(ResourceProvider.getInstance().getDrawable(ResourceProvider.ICON_SMALL)) .setLargeIcon(bitmap); if (mController != null && mController.getExtras() != null) { String castName = mController.getExtras().getString(MediaService.EXTRA_CONNECTED_CAST); if (castName != null) { CharSequence castInfo = ResourceProvider.getInstance().getString(ResourceProvider.CASTING_TO_DEVICE, castName); notificationBuilder.setSubText(castInfo); notificationBuilder.addAction( ResourceProvider.getInstance().getDrawable(ResourceProvider.ICON_CLOSE), ResourceProvider.getInstance().getString(ResourceProvider.STOP_CASTING), mStopCastIntent); } } setNotificationPlaybackState(notificationBuilder); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) notificationBuilder.mActions.clear(); return notificationBuilder.build(); }
From source file:com.appdevper.mediaplayer.app.MediaNotificationManager.java
private Notification createNotification() { LogHelper.d(TAG, "updateNotificationMetadata. mMetadata=" + mMetadata); if (mMetadata == null || mPlaybackState == null) { return null; }// w w w .j a va2s . com NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mService); int playPauseButtonPosition = 0; // If skip to previous action is enabled if ((mPlaybackState.getActions() & PlaybackState.ACTION_SKIP_TO_PREVIOUS) != 0) { notificationBuilder.addAction(R.drawable.ic_skip_previous_white_24dp, mService.getString(R.string.label_previous), mPreviousIntent); playPauseButtonPosition = 1; } addPlayPauseAction(notificationBuilder); // If skip to next action is enabled if ((mPlaybackState.getActions() & PlaybackState.ACTION_SKIP_TO_NEXT) != 0) { notificationBuilder.addAction(R.drawable.ic_skip_next_white_24dp, mService.getString(R.string.label_next), mNextIntent); } MediaDescriptionCompat description = mMetadata.getDescription(); String fetchArtUrl = null; Bitmap art = null; if (description.getIconUri() != null) { String artUrl = description.getIconUri().toString(); art = AlbumArtCache.getInstance().getBigImage(artUrl); if (art == null) { fetchArtUrl = artUrl; art = BitmapFactory.decodeResource(mService.getResources(), R.drawable.ic_default_art); } } notificationBuilder .setStyle(new NotificationCompat.MediaStyle() .setShowActionsInCompactView(new int[] { playPauseButtonPosition }) // show only play/pause in compact view .setMediaSession(mSessionToken)) .setColor(mNotificationColor).setSmallIcon(R.drawable.ic_notification) .setVisibility(Notification.VISIBILITY_PUBLIC).setUsesChronometer(true) .setContentIntent(createContentIntent(description)).setContentTitle(description.getTitle()) .setContentText(description.getSubtitle()).setLargeIcon(art); if (mController != null && mController.getExtras() != null) { String castName = mController.getExtras().getString(MusicService.EXTRA_CONNECTED_CAST); if (castName != null) { String castInfo = mService.getResources().getString(R.string.casting_to_device, castName); notificationBuilder.setSubText(castInfo); notificationBuilder.addAction(R.drawable.ic_close_black_24dp, mService.getString(R.string.stop_casting), mStopCastIntent); } } setNotificationPlaybackState(notificationBuilder); fetchBitmapFromURLAsync(fetchArtUrl, notificationBuilder); return notificationBuilder.build(); }
From source file:com.scooter1556.sms.android.manager.MediaNotificationManager.java
private Notification createNotification() { Log.d(TAG, "createNotification()"); if (mediaMetadata == null || playbackState == null) { return null; }//from w w w . j a v a 2 s.c om MediaDescriptionCompat description = mediaMetadata.getDescription(); Bitmap art = BitmapFactory.decodeResource(mediaService.getResources(), R.drawable.ic_placeholder_audio); // Notification channels are only supported on Android O+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { createNotificationChannel(); } final NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mediaService, CHANNEL_ID); final int playPauseButtonPosition = addActions(notificationBuilder); notificationBuilder.setStyle(new android.support.v4.media.app.NotificationCompat.MediaStyle() // Show only play/pause in compact view .setShowActionsInCompactView(playPauseButtonPosition).setShowCancelButton(true) .setCancelButtonIntent(stopIntent).setMediaSession(mediaSessionToken)).setDeleteIntent(stopIntent) .setColor(ContextCompat.getColor(mediaService, R.color.primary)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setSmallIcon(R.drawable.ic_notification) .setOnlyAlertOnce(true).setContentIntent(createContentIntent(description)) .setContentTitle(description.getTitle()).setContentText(description.getSubtitle()) .setLargeIcon(art); if (mediaController != null && mediaController.getExtras() != null) { String castName = mediaController.getExtras().getString(MediaService.EXTRA_CONNECTED_CAST); if (castName != null) { String castInfo = mediaService.getResources().getString(R.string.cast_to_device, castName); notificationBuilder.setSubText(castInfo); notificationBuilder.addAction(R.drawable.ic_clear_black_24dp, mediaService.getString(R.string.cast_stop), stopCastIntent); } } setNotificationPlaybackState(notificationBuilder); if (description.getIconUri() != null) { String url = description.getIconUri().toString(); url = url + "?scale=" + NOTIFICATION_ICON_SIZE; Glide.with(mediaService).asBitmap().load(url) .into(new SimpleTarget<Bitmap>(NOTIFICATION_ICON_SIZE, NOTIFICATION_ICON_SIZE) { @Override public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) { notificationBuilder.setLargeIcon(resource); notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build()); } }); } return notificationBuilder.build(); }