Reputation: 704
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
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
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):
Upvotes: 5
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