Android O: disable heads-up

Viewed 924

My application could play some audio. Once user press at the audio title the notification with the play/pause/rewind buttons appears at the notification drawer.

I noticed that in Android O (8) this notification appears with "heads-up" effect. I don't need heads-up notification, I need just silent common notification. How can I disable "heads-up" effect?

    NotificationCompat.Builder notificationBuilder;
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), Constants.CHANNEL_ID);
    } else {
        notificationBuilder = new NotificationCompat.Builder(getApplicationContext());
    }

    Notification notification = notificationBuilder
            .setSmallIcon(R.drawable.tray_icon)
            .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
            .setWhen(System.currentTimeMillis())
            .setContent(remoteViews)
            .setChannelId(Constants.CHANNEL_ID)
            .build();
    notification.defaults = 0;
0 Answers
Related