I saw this class before but cannot use it and I don't see many sample that use it. What exactly is the difference of NotificationChannelCompat
from regular NotificationChannel
?
Asked
Active
Viewed 410 times
0

Bitwise DEVS
- 2,858
- 4
- 24
- 67
-
https://developer.android.com/reference/androidx/core/app/NotificationChannelCompat – Martin Zeitler Jun 26 '22 at 03:12
-
@MartinZeitler yup I already read that before asking this question, but not satisfied with the documentation. Looks like it is lacking of explanation as to why we have this class in the first place? – Bitwise DEVS Jun 26 '22 at 03:17
1 Answers
0
NotificationChannel
s are only supported on SDK 26+. So the idea is that NotificationChannelCompat
gracefully handles the situation where you call methods related to NotificationChannel
s on unsupported SDKs. Rather than crashing your app, it simply does nothing or returns an empty list on an unsupported SDK. So this avoids the situation where you need to handle notifications differently on SDK 26+ and SDK < 26. In practice, this isn't a big deal so nobody bothers with it.

Gavin Wright
- 3,124
- 3
- 14
- 35
-
Thanks now that makes more sense and easy to understand. If only Google can make a decent documentation that is not confusing. – Bitwise DEVS Jun 26 '22 at 04:04