What backwards compatibility does
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
provide that I don't get from the normal
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
They both have a notify
method that worked on my tested devices (down to API level 19).
The Google sample here doesn't even use the Compat
version once:
https://github.com/googlesamples/android-NotificationChannels/blob/master/Application/src/main/java/com/example/android/notificationchannels/NotificationHelper.java
From looking at the source code for NotificationManagerCompat
, the bulk of the benefits are with regards to canceling notifications and determining if notifications are enabled on API 19 and below. Specifically with regard to notify(), NotificationManagerCompat
can leverage side channel notifications on older Android API levels. This allows you to register a NotificationCompatSideChannelService
that you can use to provide more robust grouping functionality on these older Android APIs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With