Google is committed to advancing racial equity for Black communities. See how.

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
Boolean
equals(other: Any?)

String!

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

Int

Returns the resource id for the recommendation badging icon.

Int

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

Bitmap!

Returns the Bitmap containing the recommendation image.

ContentRecommendation.IntentData!

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

Array<String!>!

Returns an array containing the content types tags that describe 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.

Array<String!>!

Returns an array containing the genres that describe the content.

String!

Returns the String group ID tag for this recommendation.

String!

Returns the String Id tag which uniquely identifies this recommendation.

String!

Returns the maturity level rating for the content.

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!

Gets the pricing type for the content.

String!

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

String!

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

Int

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

Int

Returns the progress amount for this recommendation.

Long

Returns the running time for the content.

String!

Returns the String sort key for this recommendation.

String!

Returns the source application name for this recommendation.

Int

Returns availability status value for the content.

String!

Returns the description text for this recommendation.

String!

Returns the content title for this recommendation.

Boolean

Indicates if this recommendation contains valid progress information.

Int

Boolean

Indicates whether this recommendation should be dismissed automatically.

Unit
setAutoDismiss(autoDismiss: Boolean)

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

Unit
setGroup(groupTag: String!)

Sets the String group ID tag for this recommendation.

Unit
setProgress(max: Int, progress: Int)

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

Unit
setSortKey(sortKey: String!)

Sets the String sort key for this recommendation.

Unit
setStatus(status: Int)

Sets the availability status value for the content.

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

equals

fun equals(other: Any?): Boolean

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.

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.

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.

getContentImage

fun getContentImage(): Bitmap!

Returns the Bitmap containing the recommendation image.

Return
Bitmap! A Bitmap containing the recommendation image.

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.

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.

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.

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.

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.

getIdTag

fun getIdTag(): String!

Returns the String Id tag which uniquely identifies this recommendation.

Return
String! The String Id tag for this recommendation.

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).

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