app/src/main/java/com/smedic/tubtub/BackgroundAudioService.java
private void buildNotification(NotificationCompat.Action action) {

        final NotificationCompat.MediaStyle style = new NotificationCompat.MediaStyle();

        Intent intent = new Intent(getApplicationContext(), BackgroundAudioService.class);
        intent.setAction(ACTION_STOP);
        PendingIntent stopPendingIntent = PendingIntent.getService(getApplicationContext(), 1, intent, 0);

        Intent clickIntent = new Intent(this, MainActivity.class);
        clickIntent.setAction(Intent.ACTION_MAIN);
        clickIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        PendingIntent clickPendingIntent = PendingIntent.getActivity(this, 0, clickIntent, 0);

        builder = new NotificationCompat.Builder(this);
        builder.setSmallIcon(R.mipmap.ic_launcher);
        builder.setContentTitle(videoItem.getTitle());
        builder.setContentInfo(videoItem.getDuration());
        builder.setShowWhen(false);
        builder.setContentIntent(clickPendingIntent);
        builder.setDeleteIntent(stopPendingIntent);
        builder.setOngoing(false);
        builder.setSubText(videoItem.getViewCount());
        builder.setStyle(style);

        //load bitmap for largeScreen
        if (videoItem.getThumbnailURL() != null && !videoItem.getThumbnailURL().isEmpty()) {
            Picasso.with(this)
                    .load(videoItem.getThumbnailURL())
                    .into(target);
        }

        builder.addAction(generateAction(android.R.drawable.ic_media_previous, "Previous", ACTION_PREVIOUS));
        builder.addAction(action);
        builder.addAction(generateAction(android.R.drawable.ic_media_next, "Next", ACTION_NEXT));
        style.setShowActionsInCompactView(0, 1, 2);

        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(1, builder.build());

    }
/**
     * Builds notification panel with buttons and info on it
     *
     * @param action Action to be applied
     */
Builds notification panel with buttons and info on it
@param action Action to be applied
Builds notification panel with buttons and info on it @param action Action to be applied
private void buildNotification(NotificationCompat.Action action) {
        final NotificationCompat.MediaStyle style = new NotificationCompat.MediaStyle();
        Intent intent = new Intent(getApplicationContext(), BackgroundAudioService.class);
        intent.setAction(ACTION_STOP);
        PendingIntent stopPendingIntent = PendingIntent.getService(getApplicationContext(), 1, intent, 0);
        Intent clickIntent = new Intent(this, MainActivity.class);
        clickIntent.setAction(Intent.ACTION_MAIN);
        clickIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        PendingIntent clickPendingIntent = PendingIntent.getActivity(this, 0, clickIntent, 0);
        builder = new NotificationCompat.Builder(this);
        builder.setSmallIcon(R.mipmap.ic_launcher);
        builder.setContentTitle(videoItem.getTitle());
        builder.setContentInfo(videoItem.getDuration());
        builder.setShowWhen(false);
        builder.setContentIntent(clickPendingIntent);
        builder.setDeleteIntent(stopPendingIntent);
        builder.setOngoing(false);
        builder.setSubText(videoItem.getViewCount());
        builder.setStyle(style);
        if (videoItem.getThumbnailURL() != null && !videoItem.getThumbnailURL().isEmpty()) {
            Picasso.with(this)
                    .load(videoItem.getThumbnailURL())
                    .into(target);
        }
        builder.addAction(generateAction(android.R.drawable.ic_media_previous, "Previous", ACTION_PREVIOUS));
        builder.addAction(action);
        builder.addAction(generateAction(android.R.drawable.ic_media_next, "Next", ACTION_NEXT));
        style.setShowActionsInCompactView(0, 1, 2);
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(1, builder.build());
    }
private void buildNotification ( NotificationCompat . Action action ) { final NotificationCompat . MediaStyle style = new NotificationCompat . MediaStyle ( ) ; Intent intent = new Intent ( getApplicationContext ( ) , BackgroundAudioService . class ) ; intent . setAction ( ACTION_STOP ) ; PendingIntent stopPendingIntent = PendingIntent . getService ( getApplicationContext ( ) , 1 , intent , 0 ) ; Intent clickIntent = new Intent ( this , MainActivity . class ) ; clickIntent . setAction ( Intent . ACTION_MAIN ) ; clickIntent . addCategory ( Intent . CATEGORY_LAUNCHER ) ; PendingIntent clickPendingIntent = PendingIntent . getActivity ( this , 0 , clickIntent , 0 ) ; builder = new NotificationCompat . Builder ( this ) ; builder . setSmallIcon ( R . mipmap . ic_launcher ) ; builder . setContentTitle ( videoItem . getTitle ( ) ) ; builder . setContentInfo ( videoItem . getDuration ( ) ) ; builder . setShowWhen ( false ) ; builder . setContentIntent ( clickPendingIntent ) ; builder . setDeleteIntent ( stopPendingIntent ) ; builder . setOngoing ( false ) ; builder . setSubText ( videoItem . getViewCount ( ) ) ; builder . setStyle ( style ) ; if ( videoItem . getThumbnailURL ( ) != null && ! videoItem . getThumbnailURL ( ) . isEmpty ( ) ) { Picasso . with ( this ) . load ( videoItem . getThumbnailURL ( ) ) . into ( target ) ; } builder . addAction ( generateAction ( android . R . drawable . ic_media_previous , "Previous" , ACTION_PREVIOUS ) ) ; builder . addAction ( action ) ; builder . addAction ( generateAction ( android . R . drawable . ic_media_next , "Next" , ACTION_NEXT ) ) ; style . setShowActionsInCompactView ( 0 , 1 , 2 ) ; NotificationManager notificationManager = ( NotificationManager ) getSystemService ( Context . NOTIFICATION_SERVICE ) ; notificationManager . notify ( 1 , builder . build ( ) ) ; }
Builds notification panel with buttons and info on it
 @param action Action to be applied
Builds notification panel with buttons and info on it @param action Action to be applied
//load bitmap for largeScreen