I am trying to get android notifications to work the way they are supposed to, as described in the documentation.
I have spent quite a long time on this and am aware of common pitfalls. Still, I have a few issues, one of them being that notifications are always displayed on my lock screen, whatever the visibility I specify on the channel and notification.
I do uninstall and re-install the app between each try, whenever I change something on the channel.
I am getting my notification manager with NotificationManagerCompat.from(context)
I am setting lock screen visibility before creating the channel:
notificationChannel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PRIVATE)
I am also setting visibility on each notification
NotificationCompat
.Builder(context, channelId)
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
// [...]
.build();
I used to call .setPublicVersion(publicSummaryNotificationBuilder.build()), where publicSummaryNotificationBuilder would build a similar notification hiding private information. I don't do it anymore: anyway the whole notifications with all details are displayed on the lock screen regardless of a public version being available or not.
I am testing on a Huawei device using EMUI, based on Android 9 Pie I (API 28). I would be tempted to blame the OS (EMUI) for this strange behavior, but other apps seem to successfully output notification with stripped private content on the lock screen.
Any idea?