Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is NotificationCompat needed?

Specifically, I think anything done with NotificationCompat can be done using the default API (level 8). What am I missing here? What does NotificationCompat introduce that cannot be done using 2.2 API?

Source: http://developer.android.com/sdk/compatibility-library.html#Notes

like image 930
AlikElzin-kilaka Avatar asked Apr 09 '12 09:04

AlikElzin-kilaka


People also ask

What is NotificationCompat?

NotificationCompat.Style. An object that can apply a rich notification style to a Notification.

What is NotificationCompat in Android?

NotificationCompat.Action. Structure to encapsulate a named action that can be shown as part of this notification.

How do I use NotificationCompat?

To make this possible, Android N uses the existing NotificationCompat. Builder. setGroup() method. Users can expand each of the notifications, and perform actions such as reply and dismiss on each of the notifications, individually from the notification shade.

What NotificationCompat builder?

Builder class for NotificationCompat objects. Allows easier control over all the flags, as well as help constructing the typical notification layouts. On platform versions that don't offer expanded notifications, methods that depend on expanded notifications have no effect.


2 Answers

You can use things like NotificationCompat.Builder#setLargeIcon(Bitmap) to allow you to take full advantage of Android 3.0+ with things like the large icon, while maintaining compatibility on versions of Android prior to 3.0 that do not support such things.

like image 134
Scott Kennedy Avatar answered Oct 27 '22 19:10

Scott Kennedy


Though its old question, now NotificationCompat can also be used to create wearable specific notifications. More information on this google's developer guide.

http://developer.android.com/training/wearables/notifications/creating.html

like image 23
Umair Avatar answered Oct 27 '22 20:10

Umair