ContentRecommendation

class ContentRecommendation
kotlin.Any
   ↳ androidx.recommendation.app.ContentRecommendation

The ContentRecommendation object encapsulates all application provided data for a single content recommendation item.

Summary

Nested classes

Builder class for ContentRecommendation objects.

Object used to encapsulate the data to be used to build the PendingIntent object associated with a given content recommendation, at the time this recommendation gets posted to the home Screen.

Constants
static String

Value to be used with Builder#setMaturityRating to indicate that the content referred by the notification is suitable for all audiences.

static String

Value to be used with Builder#setMaturityRating to indicate that the content referred by the notification is suitable for audiences of high maturity and above.

static String

Value to be used with Builder#setMaturityRating to indicate that the content referred by the notification is suitable for audiences of low maturity and above.

static String

Value to be used with Builder#setMaturityRating to indicate that the content referred by the notification is suitable for audiences of medium maturity and above.

static String

Value to be used with Builder#setPricingInformation to indicate that the content referred by the notification item is free to consume.

static String

Value to be used with Builder#setPricingInformation to indicate that the content referred by the notification item is available currently as a pre-order, and the price value provided is the purchase price for the item.

static String

Value to be used with Builder#setPricingInformation to indicate that the content referred by the notification item is available for purchase, and the price value provided is the purchase price for the item.

static String

Value to be used with Builder#setPricingInformation to indicate that the content referred by the notification item is available as a rental, and the price value provided is the rental price for the item.

static String

Value to be used with Builder#setPricingInformation to indicate that the content referred by the notification item is available as part of a subscription based service, and the price value provided is the subscription price for the service.

static Int

Value to be used with Builder#setStatus to indicate that the content referred by the notification is available, but needs to be first purchased, rented, subscribed or downloaded before it can be consumed.

static Int

Value to be used with Builder#setStatus to indicate that the content referred by the notification is pending, waiting on either a download or purchase operation to complete before it can be consumed.

static Int

Value to be used with Builder#setStatus to indicate that the content referred by the notification is available and ready to be consumed immediately.

static Int

Value to be used with Builder#setStatus to indicate that the content referred by the notification is not available.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is an application.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a book.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a comic book.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a game.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a magazine.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a movie.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a song or album.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a news item.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a podcast.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a radio station.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is serial.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is sports.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a trailer.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a video clip.

static String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a website.

static Int

Value to be used with Builder#setContentIntentData and Builder#setDismissIntentData to indicate that a PendingIntent for an Activity should be created when posting the recommendation to the HomeScreen.

static Int

Value to be used with Builder#setContentIntentData and Builder#setDismissIntentData to indicate that a PendingIntent for a Broadcast should be created when posting the recommendation to the HomeScreen.

static Int

Value to be used with Builder#setContentIntentData and Builder#setDismissIntentData to indicate that a PendingIntent for a Service should be created when posting the recommendation to the HomeScreen.

Public methods
String!

Returns the String group ID tag for this recommendation.

Notification!

Returns a Notification object which contains the content recommendation data encapsulated by this object, which can be used for posting the recommendation via the NotificationManager.

String!

Returns the description text for this recommendation.

String!

Returns the source application name for this recommendation.

String!

Returns the String sort key for this recommendation.

Boolean

Indicates if this recommendation contains valid progress information.

String!

Returns the content title for this recommendation.

Bitmap!

Returns the Bitmap containing the recommendation image.

Boolean

Indicates whether this recommendation should be dismissed automatically.

ContentRecommendation.IntentData!

Returns the data for the Intent that will be issued when the user clicks on the recommendation.

String!

Returns the maturity level rating for the content.

Unit
setSortKey(sortKey: String!)

Sets the String sort key for this recommendation.

String!

Gets the price value (when applicable) for the content.

Int

Returns availability status value for the content.

Int

Int

Returns the resource id for the recommendation badging icon.

Int

Returns the progress amount for this recommendation.

Boolean
equals(other: Any?)

Int

Returns the accent color value to be used in the UI when displaying this content recommendation to the user.

Unit
setStatus(status: Int)

Sets the availability status value for the content.

ContentRecommendation.IntentData!

Returns the data for the Intent that will be issued when the recommendation gets dismissed from the Home Screen, due to an user action.

Unit
setGroup(groupTag: String!)

Sets the String group ID tag for this recommendation.

Int

Returns the maximum value for the progress data of this recommendation.

String!

Gets the pricing type for the content.

Array<String!>!

Returns an array containing the content types tags that describe the content.

String!

Returns the primary content type tag for the recommendation, or null if no content types have been specified.

Long

Returns the running time for the content.

Array<String!>!

Returns an array containing the genres that describe the content.

Unit
setProgress(max: Int, progress: Int)

Sets the progress information for the content pointed to by this recommendation.

Unit
setAutoDismiss(autoDismiss: Boolean)

Sets the flag indicating if this recommendation should be dismissed automatically.

String!

Returns the String Id tag which uniquely identifies this recommendation.

String!

Returns a Content URI that can be used to retrieve the background image for this recommendation.

Constants

CONTENT_MATURITY_ALL

static val CONTENT_MATURITY_ALL: String

Value to be used with Builder#setMaturityRating to indicate that the content referred by the notification is suitable for all audiences.

Value: "android.contentMaturity.all"

CONTENT_MATURITY_HIGH

static val CONTENT_MATURITY_HIGH: String

Value to be used with Builder#setMaturityRating to indicate that the content referred by the notification is suitable for audiences of high maturity and above.

Value: "android.contentMaturity.high"

CONTENT_MATURITY_LOW

static val CONTENT_MATURITY_LOW: String

Value to be used with Builder#setMaturityRating to indicate that the content referred by the notification is suitable for audiences of low maturity and above.

Value: "android.contentMaturity.low"

CONTENT_MATURITY_MEDIUM

static val CONTENT_MATURITY_MEDIUM: String

Value to be used with Builder#setMaturityRating to indicate that the content referred by the notification is suitable for audiences of medium maturity and above.

Value: "android.contentMaturity.medium"

CONTENT_PRICING_FREE

static val CONTENT_PRICING_FREE: String

Value to be used with Builder#setPricingInformation to indicate that the content referred by the notification item is free to consume.

Value: "android.contentPrice.free"

CONTENT_PRICING_PREORDER

static val CONTENT_PRICING_PREORDER: String

Value to be used with Builder#setPricingInformation to indicate that the content referred by the notification item is available currently as a pre-order, and the price value provided is the purchase price for the item.

Value: "android.contentPrice.preorder"

CONTENT_PRICING_PURCHASE

static val CONTENT_PRICING_PURCHASE: String

Value to be used with Builder#setPricingInformation to indicate that the content referred by the notification item is available for purchase, and the price value provided is the purchase price for the item.

Value: "android.contentPrice.purchase"

CONTENT_PRICING_RENTAL

static val CONTENT_PRICING_RENTAL: String

Value to be used with Builder#setPricingInformation to indicate that the content referred by the notification item is available as a rental, and the price value provided is the rental price for the item.

Value: "android.contentPrice.rental"

CONTENT_PRICING_SUBSCRIPTION

static val CONTENT_PRICING_SUBSCRIPTION: String

Value to be used with Builder#setPricingInformation to indicate that the content referred by the notification item is available as part of a subscription based service, and the price value provided is the subscription price for the service.

Value: "android.contentPrice.subscription"

CONTENT_STATUS_AVAILABLE

static val CONTENT_STATUS_AVAILABLE: Int

Value to be used with Builder#setStatus to indicate that the content referred by the notification is available, but needs to be first purchased, rented, subscribed or downloaded before it can be consumed.

Value: 2

CONTENT_STATUS_PENDING

static val CONTENT_STATUS_PENDING: Int

Value to be used with Builder#setStatus to indicate that the content referred by the notification is pending, waiting on either a download or purchase operation to complete before it can be consumed.

Value: 1

CONTENT_STATUS_READY

static val CONTENT_STATUS_READY: Int

Value to be used with Builder#setStatus to indicate that the content referred by the notification is available and ready to be consumed immediately.

Value: 0

CONTENT_STATUS_UNAVAILABLE

static val CONTENT_STATUS_UNAVAILABLE: Int

Value to be used with Builder#setStatus to indicate that the content referred by the notification is not available. This could be content not available in a certain region or incompatible with the device in use.

Value: 3

CONTENT_TYPE_APP

static val CONTENT_TYPE_APP: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is an application.

Value: "android.contentType.app"

CONTENT_TYPE_BOOK

static val CONTENT_TYPE_BOOK: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a book.

Value: "android.contentType.book"

CONTENT_TYPE_COMIC

static val CONTENT_TYPE_COMIC: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a comic book.

Value: "android.contentType.comic"

CONTENT_TYPE_GAME

static val CONTENT_TYPE_GAME: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a game.

Value: "android.contentType.game"

CONTENT_TYPE_MAGAZINE

static val CONTENT_TYPE_MAGAZINE: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a magazine.

Value: "android.contentType.magazine"

CONTENT_TYPE_MOVIE

static val CONTENT_TYPE_MOVIE: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a movie.

Value: "android.contentType.movie"

CONTENT_TYPE_MUSIC

static val CONTENT_TYPE_MUSIC: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a song or album.

Value: "android.contentType.music"

CONTENT_TYPE_NEWS

static val CONTENT_TYPE_NEWS: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a news item.

Value: "android.contentType.news"

CONTENT_TYPE_PODCAST

static val CONTENT_TYPE_PODCAST: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a podcast.

Value: "android.contentType.podcast"

CONTENT_TYPE_RADIO

static val CONTENT_TYPE_RADIO: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a radio station.

Value: "android.contentType.radio"

CONTENT_TYPE_SERIAL

static val CONTENT_TYPE_SERIAL: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is serial. It can refer to an entire show, a single season or series, or a single episode.

Value: "android.contentType.serial"

CONTENT_TYPE_SPORTS

static val CONTENT_TYPE_SPORTS: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is sports.

Value: "android.contentType.sports"

CONTENT_TYPE_TRAILER

static val CONTENT_TYPE_TRAILER: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a trailer.

Value: "android.contentType.trailer"

CONTENT_TYPE_VIDEO

static val CONTENT_TYPE_VIDEO: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a video clip.

Value: "android.contentType.video"

CONTENT_TYPE_WEBSITE

static val CONTENT_TYPE_WEBSITE: String

Value to be used with Builder#setContentTypes to indicate that the content referred by the notification item is a website.

Value: "android.contentType.website"

INTENT_TYPE_ACTIVITY

static val INTENT_TYPE_ACTIVITY: Int

Value to be used with Builder#setContentIntentData and Builder#setDismissIntentData to indicate that a PendingIntent for an Activity should be created when posting the recommendation to the HomeScreen.

Value: 1

INTENT_TYPE_BROADCAST

static val INTENT_TYPE_BROADCAST: Int

Value to be used with Builder#setContentIntentData and Builder#setDismissIntentData to indicate that a PendingIntent for a Broadcast should be created when posting the recommendation to the HomeScreen.

Value: 2

INTENT_TYPE_SERVICE

static val INTENT_TYPE_SERVICE: Int

Value to be used with Builder#setContentIntentData and Builder#setDismissIntentData to indicate that a PendingIntent for a Service should be created when posting the recommendation to the HomeScreen.

Value: 3

Public methods

getGroup

fun getGroup(): String!

Returns the String group ID tag for this recommendation.

Return
String!: A String containing the group ID tag for this recommendation.

getNotificationObject

fun getNotificationObject(context: Context!): Notification!

Returns a Notification object which contains the content recommendation data encapsulated by this object, which can be used for posting the recommendation via the NotificationManager.

Parameters
context Context!: A Context that will be used to construct the Notification object which will carry the recommendation data.
Return
Notification!: A Notification containing the stored recommendation data.

getText

fun getText(): String!

Returns the description text for this recommendation.

Return
String!: A String containing the recommendation description text.

getSourceName

fun getSourceName(): String!

Returns the source application name for this recommendation.

Return
String!: A String containing the recommendation source name.

getSortKey

fun getSortKey(): String!

Returns the String sort key for this recommendation.

Return
String!: A String containing the sort key for this recommendation.

hasProgressInfo

fun hasProgressInfo(): Boolean

Indicates if this recommendation contains valid progress information.

Return
Boolean: true if the recommendation contains valid progress data, false otherwise.

getTitle

fun getTitle(): String!

Returns the content title for this recommendation.

Return
String!: A String containing the recommendation content title.

getContentImage

fun getContentImage(): Bitmap!

Returns the Bitmap containing the recommendation image.

Return
Bitmap!: A Bitmap containing the recommendation image.

isAutoDismiss

fun isAutoDismiss(): Boolean

Indicates whether this recommendation should be dismissed automatically.

Auto-dismiss notifications are automatically removed from the Home Screen when the user clicks on them.

Return
Boolean: true if the recommendation is marked for auto dismissal, or false otherwise.

getContentIntent

fun getContentIntent(): ContentRecommendation.IntentData!

Returns the data for the Intent that will be issued when the user clicks on the recommendation.

Return
ContentRecommendation.IntentData!: An IntentData object, containing the data for the Intent that gets issued when the recommendation is clicked on.

getMaturityRating

fun getMaturityRating(): String!

Returns the maturity level rating for the content.

Return
String!: returns a predefined tag indicating the maturity level rating for the content (see the CONTENT_MATURITY_* constants).

setSortKey

fun setSortKey(sortKey: String!): Unit

Sets the String sort key for this recommendation.

The sort key must be a String representation of a float number between 0.0 and 1.0, and is used to indicate the relative importance (and sort order) of a single recommendation within its specified group. The recommendations will be ordered in decreasing order of importance within a given group.

Parameters
sortKey String!: A String containing the sort key for this recommendation.

getPricingValue

fun getPricingValue(): String!

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

Return
String!: A string containing a representation of the content price in the current locale and currency.

getStatus

fun getStatus(): Int

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

Return
Int: The status value for the content, or -1 is a valid status has not been specified (see the CONTENT_STATUS_* constants for the valid status values).

hashCode

fun hashCode(): Int

getBadgeImageResourceId

fun getBadgeImageResourceId(): Int

Returns the resource id for the recommendation badging icon.

The resource id represents the icon resource in the source application package.

Return
Int: An integer id for the badge icon resource.

getProgressValue

fun getProgressValue(): Int

Returns the progress amount for this recommendation.

Return
Int: An integer representing the recommendation progress amount.

equals

fun equals(other: Any?): Boolean

getColor

fun getColor(): Int

Returns the accent color value to be used in the UI when displaying this content recommendation to the user.

Return
Int: An integer value representing the accent color for this recommendation.

setStatus

fun setStatus(status: Int): Unit

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

Parameters
status Int: The status value for the content. (see the CONTENT_STATUS_* for the valid status values).

getDismissIntent

fun getDismissIntent(): ContentRecommendation.IntentData!

Returns the data for the Intent that will be issued when the recommendation gets dismissed from the Home Screen, due to an user action.

Return
ContentRecommendation.IntentData!: An IntentData object, containing the data for the Intent that gets issued when the recommendation is dismissed from the Home Screen.

setGroup

fun setGroup(groupTag: String!): Unit

Sets the String group ID tag for this recommendation.

Recommendations in the same group are ranked by the Home Screen together, and the sort order within a group is respected. This can be useful if the application has different sources for recommendations, like "trending", "subscriptions", and "new music" categories for YouTube, where the user can be more interested in recommendations from one group than another.

Parameters
groupTag String!: A String containing the group ID tag for this recommendation.

getProgressMax

fun getProgressMax(): Int

Returns the maximum value for the progress data of this recommendation.

Return
Int: An integer representing the maximum progress value.

getPricingType

fun getPricingType(): String!

Gets the pricing type for the content.

Return
String!: A predefined tag indicating the pricing type for the content (see the CONTENT_PRICING_* constants).

getContentTypes

fun getContentTypes(): Array<String!>!

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

Return
Array<String!>!: An array of predefined type tags (see the CONTENT_TYPE_* constants) that describe the recommended content.

getPrimaryContentType

fun getPrimaryContentType(): String!

Returns the primary content type tag for the recommendation, or null if no content types have been specified.

Return
String!: A predefined type tag (see the CONTENT_TYPE_* constants) indicating the primary content type for the recommendation.

getRunningTime

fun getRunningTime(): Long

Returns the running time for the content.

Return
Long: The run length, in seconds, of the content associated with the notification.

getGenres

fun getGenres(): Array<String!>!

Returns an array containing the genres that describe the content. Genres are open ended String tags.

Return
Array<String!>!: An array of genre tags that describe the recommended content.

setProgress

fun setProgress(max: Int, progress: Int): Unit

Sets the progress information for the content pointed to by this recommendation.

Parameters
max Int: The maximum value for the progress of this content.
progress Int: The progress amount for this content. Must be in the range (0 - max).

setAutoDismiss

fun setAutoDismiss(autoDismiss: Boolean): Unit

Sets the flag indicating if this recommendation should be dismissed automatically.

Auto-dismiss notifications are automatically removed from the Home Screen when the user clicks on them.

Parameters
autoDismiss Boolean: A boolean indicating if the recommendation should be auto dismissed or not.

getIdTag

fun getIdTag(): String!

Returns the String Id tag which uniquely identifies this recommendation.

Return
String!: The String Id tag for this recommendation.

getBackgroundImageUri

fun getBackgroundImageUri(): String!

Returns a Content URI that can be used to retrieve the background image for this recommendation.

Return
String!: A Content URI pointing to the recommendation background image.