Android O: disable heads-up
Asked Answered
C

0

9

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;
Cadaverine answered 12/11, 2017 at 9:39 Comment(3)
did you find anything about it?Mortensen
It probably depends how exactly you define your notificantion channel, e.g. create it with IMPORTANCE_NORMAL instead of IMPORTANCE_HIGH. However I have a reverse problem, I want the "heads-up" effect on Oreo too, but it never works. Could you please post the code of your channel creation too, so that I could learn?Rambler
Any solution @RamblerStreamway

© 2022 - 2024 — McMap. All rights reserved.