Created
June 17, 2016 07:10
-
-
Save atlantis0/dbbf5ba4c5a4dddb2f575740683ec401 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
private void showNotification(boolean playing) { | |
NotificationCompat.Builder builder = from(getApplicationContext(), ...); | |
builder.setSmallIcon(R.drawable.ic_radio_black_24dp); // set small icon | |
builder.setColor(getResources().getColor(R.color.colorPrimary)); // set accent color | |
builder.setContentTitle(this.mMediaMetaData.getRadioStation() + " - " + | |
this.mMediaMetaData.getProgramName()); | |
builder.setSubText(this.mMediaMetaData.getProgramHost()); | |
// set actions here | |
if(playing) { | |
builder.addAction(new NotificationCompat.Action(R.drawable.ic_pause_notification, "Pause", | |
getActionIntent(this, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE))); | |
builder.setOngoing(true); | |
} | |
else | |
builder.addAction(new NotificationCompat.Action(R.drawable.ic_play_notification, "Play", | |
getActionIntent(this, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE))); | |
builder.addAction(new NotificationCompat.Action(R.drawable.ic_stop_notification, "Stop", | |
getActionIntent(this, KeyEvent.KEYCODE_MEDIA_STOP))); | |
builder.setStyle(new NotificationCompat.MediaStyle() | |
.setShowActionsInCompactView(0).setMediaSession(mMediaSession.getSessionToken()) | |
.setShowCancelButton(true).setCancelButtonIntent(getActionIntent(getApplicationContext(), | |
KeyEvent.KEYCODE_MEDIA_STOP))); | |
startForeground(SHEGER_MEDIA_NOTIFICATION_ID, builder.build()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment