JonasOliveira
JonasOliveira

Reputation: 704

After setLockscreenVisibility(Notification.VISIBILITY_SECRET) the notification channel is still appearing on lockscreen

After set a notification channel to not show notifications at lockscreen, it still is showing the notifications on lockscreen.

notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
notificationManager.createNotificationChannel(notificationChannel);

But after the creation of the channel I can debug it and see that the notification channel does not have the lockScreenVisibility set to VISIBILITY_SECRET (-1), it still has the default value, that is -1000.

notificationChannel.getLockscreenVisibility()

Does anyone knows how to set the lockscreen visibility to not show on lockscreen? Or have any idea why it is not being updated?

One more information is that I already have created the channel previously. But I have deleted and recreated the channel with the VISIBILITY_SECRET.

Upvotes: 4

Views: 8339

Answers (3)

SergeyT
SergeyT

Reputation: 850

The documentation says that setLockscreenVisibility and setBypassDnd are "Only modifiable by the system and notification ranker."

The suggestion of @WillNewton works only after you have manually changed this settings.

Upvotes: 1

Will Newton
Will Newton

Reputation: 61

The reason this may be happening is that even secret notifications are show on the lock screen if the lock screen is not secure (e.g. a PIN is not set):

https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r33/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java#521

Upvotes: 5

ianhanniballake
ianhanniballake

Reputation: 200120

When you delete and recreate a channel, all of the previous settings are restored. You must create a brand new channel (with a different channel ID) or completely uninstall/reinstall the app if you want to change anything other than the channel's name or description.

Upvotes: 10

Related Questions