/** Call this to build the {@link Notification}. */ public void buildNotification( final String albumName, final String artistName, final String trackName, final Long albumId, final Bitmap albumArt, final boolean isPlaying) { // Default notification layout mNotificationTemplate = new RemoteViews(mService.getPackageName(), R.layout.notification_template_base); // Set up the content view initCollapsedLayout(trackName, artistName, albumArt); // Save this for debugging PendingIntent pendingintent = getPendingIntent(); // Notification Builder Notification aNotification = new NotificationCompat.Builder(mService) .setSmallIcon(getNotificationIcon()) .setContentIntent(pendingintent) .setPriority(0) // (Notification.PRIORITY_DEFAULT) .setContent(mNotificationTemplate) .build(); // Control playback from the notification initPlaybackActions(isPlaying); // Expanded notification style mExpandedView = new RemoteViews(mService.getPackageName(), R.layout.notification_template_expanded_base); aNotification.bigContentView = mExpandedView; // Control playback from the notification initExpandedPlaybackActions(isPlaying); // Set up the expanded content view initExpandedLayout(trackName, albumName, artistName, albumArt); mNotification = aNotification; mService.startForeground(APOLLO_MUSIC_SERVICE, mNotification); }
/** * Constructor of <code>NotificationHelper</code> * * @param service The {@link Context} to use */ public NotificationHelper(final MusicPlaybackService service) { mService = service; mNotificationManager = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE); }
/** Remove notification */ public void killNotification() { mService.stopForeground(true); mNotification = null; }