Android APIs
public final class

RecommendationExtender

extends Object
implements Notification.Extender
java.lang.Object
   ↳ android.support.app.recommendation.RecommendationExtender

Class Overview

Helper class to add content info extensions to notifications. To create a notification with content info extensions:

  1. Create an Notification.Action.Builder, setting any desired properties.
  2. Create a RecommendationExtender.
  3. Set content info specific properties using the add and set methods of RecommendationExtender.
  4. Call Notification.Builder.extend(Notification.Extender) to apply the extensions to a notification.
Notification notification = new Notification.Builder(context) * ... * .extend(new RecommendationExtender() * .set*(...)) * .build(); * 

Content info extensions can be accessed on an existing notification by using the RecommendationExtender(Notification) constructor, and then using the get methods to access values.

Summary

Public Constructors
RecommendationExtender()
Create a RecommendationExtender with default options.
RecommendationExtender(Notification notif)
Create a RecommendationExtender from the RecommendationExtender options of an existing Notification.
Public Methods
Notification.Builder extend(Notification.Builder builder)
Apply content extensions to a notification that is being built.
String[] getContentTypes()
Returns an array containing the content types that describe the content associated with the notification.
String[] getGenres()
Returns an array containing the content genres that describe the content associated with the notification.
String getMaturityRating()
Returns the maturity level rating for the content associated with the notification.
String getPricingType()
Gets the pricing type for the content associated with the notification.
String getPricingValue()
Gets the price value (when applicable) for the content associated with a notification.
String getPrimaryContentType()
Returns the primary content type tag for the content associated with the notification.
long getRunningTime()
Returns the running time for the content associated with the notification.
int getStatus()
Returns status value for the content associated with the notification.
RecommendationExtender setContentTypes(String[] types)
Sets the content types associated with the notification content.
RecommendationExtender setGenres(String[] genres)
Sets the content genres associated with the notification content.
RecommendationExtender setMaturityRating(String maturityRating)
Sets the maturity level rating for the content associated with the notification.
RecommendationExtender setPricingInformation(String priceType, String priceValue)
Sets the pricing and availability information for the content associated with the notification.
RecommendationExtender setRunningTime(long length)
Sets the running time (when applicable) for the content associated with the notification.
RecommendationExtender setStatus(int contentStatus)
Sets the availability status for the content associated with the notification.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.app.Notification.Extender

Public Constructors

public RecommendationExtender ()

Create a RecommendationExtender with default options.

public RecommendationExtender (Notification notif)

Create a RecommendationExtender from the RecommendationExtender options of an existing Notification.

Parameters
notif The notification from which to copy options.

Public Methods

public Notification.Builder extend (Notification.Builder builder)

Apply content extensions to a notification that is being built. This is typically called by the Notification.Builder.extend(Notification.Extender) method of Notification.Action.Builder.

Parameters
builder the builder to be modified.
Returns
  • the build object for chaining.

public String[] getContentTypes ()

Returns an array containing the content types that describe the content associated with the notification. The first tag entry is considered the primary type for the content, and is used for content ranking purposes.

Returns
  • An array of predefined type tags (see the CONTENT_TYPE_* constants) that describe the content associated with the notification.

public String[] getGenres ()

Returns an array containing the content genres that describe the content associated with the notification.

Returns
  • An array of genre tags that describe the content associated with the notification.

public String getMaturityRating ()

Returns the maturity level rating for the content associated with the notification.

Returns
  • returns a predefined tag indicating the maturity level rating for the content (see the CONTENT_MATURITY_* constants).

public String getPricingType ()

Gets the pricing type for the content associated with the notification.

Returns
  • A predefined tag indicating the pricing type for the content (see the CONTENT_PRICING_* constants).

public String getPricingValue ()

Gets the price value (when applicable) for the content associated with a notification. The value will be provided as a String containing the price in the appropriate currency for the current locale.

Returns
  • A string containing a representation of the content price in the current locale and currency.

public String getPrimaryContentType ()

Returns the primary content type tag for the content associated with the notification.

Returns
  • A predefined type tag (see the CONTENT_TYPE_* constants) indicating the primary type for the content associated with the notification.

public long getRunningTime ()

Returns the running time for the content associated with the notification.

Returns
  • The running time, in seconds, of the content associated with the notification.

public int getStatus ()

Returns status value for the content associated with the notification. This status indicates whether the referred content is ready to be consumed on the device, or if the user must first purchase, rent, subscribe to, or download the content.

Returns
  • The status value for this content, or -1 is a valid status has not been specified (see the CONTENT_STATUS_* for the defined valid status values).
See Also

public RecommendationExtender setContentTypes (String[] types)

Sets the content types associated with the notification content. The first tag entry will be considered the primary type for the content and will be used for ranking purposes. Other secondary type tags may be provided, if applicable, and may be used for filtering purposes.

Parameters
types Array of predefined type tags (see the CONTENT_TYPE_* constants) that describe the content referred to by a notification.

public RecommendationExtender setGenres (String[] genres)

Sets the content genres associated with the notification content. These genres may be used for content ranking. Genres are open ended String tags.

Some examples: "comedy", "action", "dance", "electronica", "racing", etc.

Parameters
genres Array of genre string tags that describe the content referred to by a notification.

public RecommendationExtender setMaturityRating (String maturityRating)

Sets the maturity level rating for the content associated with the notification.

Parameters
maturityRating A tag indicating the maturity level rating for the content. This tag must be one of the predefined maturity rating tags (see the CONTENT_MATURITY_* constants).

public RecommendationExtender setPricingInformation (String priceType, String priceValue)

Sets the pricing and availability information for the content associated with the notification. The provided information will indicate the access model for the content (free, rental, purchase or subscription) and the price value (if not free).

Parameters
priceType Pricing type for this content. Must be one of the predefined pricing type tags (see the CONTENT_PRICING_* constants).
priceValue A string containing a representation of the content price in the current locale and currency.
Returns
  • This object for method chaining.

public RecommendationExtender setRunningTime (long length)

Sets the running time (when applicable) for the content associated with the notification.

Parameters
length The runing time, in seconds, of the content associated with the notification.

public RecommendationExtender setStatus (int contentStatus)

Sets the availability status for the content associated with the notification. This status indicates whether the referred content is ready to be consumed on the device, or if the user must first purchase, rent, subscribe to, or download the content.

Parameters
contentStatus The status value for this content. Must be one of the predefined content status values (see the CONTENT_STATUS_* constants).