Does NotificationManagerCompat only have wear-spec

2019-07-29 06:15发布

问题:

The Android tutorials say to use NotificationManagerCompat class to show notifications, but since this class has no createNotificationChannels method, it's a bit awkward to handle 2 different NotificationManagers.

From my search online it seems that all internal features of NotificationManagerCompat are specific to Android Wear and have no effect on phone/tablet. Is that observation correct?

回答1:

As stated the NotificationManagerCompat is a "Compatibility library for NotificationManager with fallbacks for older platforms."

It holds in it and IMPL class that behaves differently according to the platform it is installed upon. you can have a look at: NotificationManagerCompat.java

I'm not sure how differently it behaves but what it actually does is overrides certain methods that deal with posting, canceling and checking if notifications are enabled.