simple
simple

Reputation: 159

How to avoid Heads-up notification on android Oreo and above?

I want to show the notification in the background. Means, while user opening the notification screen.

But its coming on the top of my app screen. I don't want to show at the top of the my app.

I want to show only in the notification bar.

Can someone suggest, what is the property that I have to set.

Upvotes: 2

Views: 721

Answers (1)

shb
shb

Reputation: 6277

Make sure your activity is not full screen.

Set low priority to your notification

NotificationCompat.Builder mBuilder.setContentTitle(fileName)
                .setContentText("Notification")
                .setSmallIcon(R.drawable.icon)
                .setPriority(NotificationCompat.PRIORITY_LOW)
                .setAutoCancel(true)
                .setContentIntent(pendingIntent);

and low importance to your notification channel

NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, IMPORTANCE_LOW);

Upvotes: 3

Related Questions