Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are notification categories assigned in Android L preview/API 20

According to the "Design for Notifications" document, notifications can (and should) include a category when they are created. Categories include things like calls, messages, promotions, progress notifications, system messages, and social updates.

In addition to enumerating the categories, actual system library constants are listed on the page, like Notification.CATEGORY_CALL, Notification.CATEGORY_PROGRESS, and Notification.CATEGORY_SOCIAL.

However, these constants, and the whole category system, seems only to be mentioned in the "Design for Notifications" page. At this writing, the API documentation for Notification doesn't include those constants, and there doesn't seem to be any method like setCategory documented in Notification.Builder. A Google search for "Notification.CATEGORY_PROGRESS" turns up only the "Design for Notifications" document.

Does anybody out there know how to actually use these categories, and assign them to your notifications in L preview?

EDIT:

A peek at the current Notification source code in the current aosp/preview-l branch shows no evidence of the constants. Could this be a feature that didn't make the cut for the release? (If so, is there anybody out there who might be able to confirm that?)

For reference:

"Design for Notifications" : https://developer.android.com/preview/notifications.html#set_a_notification_category

That Google search that turns up nothing : https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=%22Notification.CATEGORY_PROGRESS%22

EDIT:

A-C's answer below seems to indicate that categories will be in the release but not the preview (although they might indicate the features were removed from the release). The constants and appropriate builder interface are documented in them.

EDIT:

The category constants and setCategory method were included in the API 21/Lollipop release. They're not all that well documented but they are present.

like image 705
user128536 Avatar asked Oct 31 '22 20:10

user128536


1 Answers

The L Developer Preview Documentation contains the constants as well as a setCategory() method in the both regular and compatibility Builder classes.

Thus, the category is set manually.

However, as you have noticed the l-preview source doesn't include them.

Without an actual Android team member to answer your question, I'd conclude that it will be a feature in the final release, but won't actually be available in the preview unless they plan on making multiple preview releases.

like image 85
A--C Avatar answered Nov 11 '22 03:11

A--C