How can I have custom CallStyle notification to be non-dismissable on Android 14?

241 Views Asked by At

Android 14 forces to use CallStyle to have non-dismissable notifications:

This change applies to apps that prevent users from dismissing foreground notifications by setting Notification.FLAG_ONGOING_EVENT through Notification.Builder#setOngoing(true) or NotificationCompat.Builder#setOngoing(true). The behavior of FLAG_ONGOING_EVENT has changed to make such notifications actually dismissable by the user.

This new behavior doesn't apply to notifications in the following use cases: CallStyle notifications Device policy controller (DPC) and supporting packages for enterprise

I've had a custom style for Android <14 and non-dismissable:

NotificationCompat.Builder(context, INCOMING_CALL_CHANNEL_ID)
            .setSmallIcon(R.drawable.logo_light)
            .setColor(ContextCompat.getColor(context, R.color.colorPrimary))
            .setPriority(NotificationCompat.PRIORITY_HIGH)
            .setStyle(NotificationCompat.DecoratedCustomViewStyle())
            .setCustomContentView(notificationLayout)
            .setFullScreenIntent(setViewNotificationClick(conferenceRoom, member), true)
            .setCustomHeadsUpContentView(notificationLayout)
            .setOngoing(true)
            .setAutoCancel(true)
            .setDeleteIntent(getTimeDestroyNotificationPendingIntent(context,conferenceRoom))
            .setTimeoutAfter(30000)
            .build()

But now I have to use a premade style to have non-dismissable notifications for incoming calls or ongoing notifications. How can I access custom decoration style along with non-dismisable notification at the same time?

0

There are 0 best solutions below