Notification fixed at the top

Asked

Viewed 212 times

2

I created a Notification but it always compresses and goes down, I would like to leave it always expanded and always at the top of notifications

  • Hi Aleff, can you post the code here? It’s easier ; )

  • 1

    Try notification.flags |= Notification.FLAG_ONGOING_EVENT; and/or notification.priority = Notification.PRIORITY_MAX;

  • even so it still gets compressed when comes something like the Whatsapp or something like that

1 answer

2

Just add the flag Notification.FLAG_ONGOING_EVENT in his Notification.

suaNotificacao.flags = Notification.FLAG_ONGOING_EVENT;

If you want to add more than one flag to your Notification, utilize |= to assign, for example:

suaNotificacao.flags |= Notification.FLAG_ONGOING_EVENT;
suaNotificacao.flags |= Notification.FLAG_SHOW_LIGHTS;

If you are using NotificationCompat.Builder, you can use the method setOngoing():

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
mBuilder.setOngoing(true);
  • even so it still gets compressed when comes something like the Whatsapp or something like that

Browser other questions tagged

You are not signed in. Login or sign up in order to post.