Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does NotificationCompat and NotificationManagerCompat have to be used for notifications to appear on a wearable?

I'm a bit confused by the documentation for wearable notifications.

If I have an existing app that is using Notification.Builder and NotificationManager.notify() will the notifications automatically also display on a paired wearable or does the app need to change to use NotificationCompat.Builder and NotificationManagerCompat.notify()?

If its not necessary to use the XXXCompat classes for notifications to appear on the wearable then is there any benefit/use in using them instead of the non Compat variants?

like image 217
Gruntcakes Avatar asked Feb 12 '23 21:02

Gruntcakes


1 Answers

NotificationManagerCompat is required for all Wear specific functionality (anything added via a WearableExtender, a part of NotificationCompat.Builder) per delivering notifications:

If you use the framework's NotificationManager, some features from NotificationCompat.WearableExtender do not work, so make sure to use NotificationCompat.

However, basic notifications sent via NotificationManager will indeed be mirrored over the Android Wear devices without issues.

As CommonsWare alluded to in his comment, it is much, much easier to write Notifications that look good on all API versions by using NotificationCompat. This will become even more important when Android L comes out (where there are numerous Android L notification changes) which, unless you are targeting Android L+ devices only, you'll need to use NotificationCompat to access.

like image 83
ianhanniballake Avatar answered Feb 26 '23 21:02

ianhanniballake