如何使通知停留在最前面? [英] How to make notification stay on top?

查看:231
本文介绍了如何使通知停留在最前面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一条通知,我一直想保持在最前.

我已经给它设置了2的优先级

大多数情况下它停留在顶部,但是,假设有一个开放的WiFi网络,那么我的通知就会消失,而打开的WiFi网络的通知会放在顶部位置.

但是当我查看vlc(用于Android)支付歌曲的通知时,vlc的通知仍然排在最前面,而打开的WiFi网络的通知却消失了.

我的通知正在进行中,优先级为2.

我该怎么办.我是一个初学者,所以请多多包涵.

在此先感谢.

解决方案

您尝试过此方法

  NotificationCompat.Builder builder =(NotificationCompat.Builder)新的NotificationCompat.Builder(上下文).setSmallIcon(R.drawable.notify_icon).setContentTitle("Notification").setContentText(在顶部").setPriority(Notification.PRIORITY_MAX); 

优先级-> PRIORITY_MAX / PRIORITY_HIGH / PRIORITY_DEFAULT / PRIORITY_LOW / PRIORITY_MIN

阅读 https://material.google.com/patterns/notifications.html#correctly_set_and_manage_notification_priority

https://developer.android.com/reference/android/app/Notification.html#priority

正如StenSoft所说 Android:如何创建正在进行的"通知吗?

I have a notification which I always want to stay on top.

I have already given it a priority of 2

Mostly it stays on top but, suppose there is a open WiFi network, then my notification goes down and the notification of open WiFi network comes on the top position.

But when I looked at the notification of vlc(for Android) paying a song, the notification of vlc stay on top and the notification of open WiFi network goes down.

I notification is ongoing and with priority 2.

What should I do. I am a beginner so please bear with me.

And thanks in advance.

解决方案

have you tried this

NotificationCompat.Builder builder =
            (NotificationCompat.Builder) new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.notify_icon)
            .setContentTitle("Notification")
            .setContentText("ON Top")
            .setPriority(Notification.PRIORITY_MAX);

Priority Levels --> PRIORITY_MAX / PRIORITY_HIGH /PRIORITY_DEFAULT /PRIORITY_LOW /PRIORITY_MIN

read https://material.google.com/patterns/notifications.html#correctly_set_and_manage_notification_priority

https://developer.android.com/reference/android/app/Notification.html#priority

and as StenSoft said Android: How to create an "Ongoing" notification?

这篇关于如何使通知停留在最前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆