Created
August 11, 2017 22:04
-
-
Save nazmulidris/4a2bd2f98675c059bd427bc1296af6ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.support.v4.app.NotificationCompat; | |
import android.support.v4.content.ContextCompat; | |
import android.support.v4.media.app.NotificationCompat.MediaStyle; | |
//... | |
// You only need to create the channel on API 26+ devices | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
createChannel(); | |
} | |
NotificationCompat.Builder notificationBuilder = | |
new NotificationCompat.Builder(mContext, CHANNEL_ID); | |
notificationBuilder | |
.setStyle( | |
new MediaStyle() | |
.setMediaSession(token) | |
.setShowCancelButton(true) | |
.setCancelButtonIntent( | |
MediaButtonReceiver.buildMediaButtonPendingIntent( | |
mContext, PlaybackStateCompat.ACTION_STOP))) | |
.setColor(ContextCompat.getColor(mContext, R.color.notification_bg)) | |
.setSmallIcon(R.drawable.ic_stat_image_audiotrack) | |
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) | |
.setOnlyAlertOnce(true) | |
.setContentIntent(createContentIntent()) | |
.setContentTitle(“Album”) | |
.setContentText(“Artist”) | |
.setSubText(“Song Name”) | |
.setLargeIcon(MusicLibrary.getAlbumBitmap(mContext, description.getMediaId())) | |
.setDeleteIntent(MediaButtonReceiver.buildMediaButtonPendingIntent( | |
mService, PlaybackStateCompat.ACTION_STOP)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment