Android 12 Developer Preview is here! Try it out, and give us your feedback!

Builder

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

Builder class for ContentRecommendation objects. Provides a convenient way to set the various fields of a ContentRecommendation.

Example:

ContentRecommendation rec = new ContentRecommendation.Builder()
              .setIdInfo(id, "MyTagId")
              .setTitle("My Content Recommendation")
              .setText("An example of content recommendation")
              .setContentImage(myBitmap)
              .setBadgeIcon(R.drawable.app_icon)
              .setGroup("Trending")
              .build();
      

Summary

Public constructors

Constructs a new Builder.

Public methods
ContentRecommendation!

Combine all of the options that have been set and return a new ContentRecommendation object.

ContentRecommendation.Builder!
setAutoDismiss(autoDismiss: Boolean)

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

ContentRecommendation.Builder!
setBackgroundImageUri(@Nullable imageUri: String?)

Sets the Content URI that will be used to retrieve the background image for the recommendation.

ContentRecommendation.Builder!
setBadgeIcon(@DrawableRes iconResourceId: Int)

Sets the resource ID for the recommendation badging icon.

ContentRecommendation.Builder!
setColor(@ColorInt color: Int)

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

ContentRecommendation.Builder!

Sets the recommendation image.

ContentRecommendation.Builder!
setContentIntentData(intentType: Int, intent: Intent!, requestCode: Int, @Nullable options: Bundle?)

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

ContentRecommendation.Builder!

Sets the content types associated with the content recommendation.

ContentRecommendation.Builder!
setDismissIntentData(intentType: Int, @Nullable intent: Intent?, requestCode: Int, @Nullable options: Bundle?)

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

ContentRecommendation.Builder!
setGenres(genres: Array<String!>!)

Sets the content genres for the recommendation.

ContentRecommendation.Builder!
setGroup(@Nullable groupTag: String?)

Sets the String group ID tag for the recommendation.

ContentRecommendation.Builder!
setIdTag(idTag: String!)

Sets the Id tag that uniquely identifies this recommendation object.

ContentRecommendation.Builder!
setMaturityRating(maturityRating: String!)

Sets the maturity level rating for the content.

ContentRecommendation.Builder!
setPricingInformation(priceType: String!, @Nullable priceValue: String?)

Sets the pricing and availability information for the recommendation.

ContentRecommendation.Builder!
setProgress(max: Int, progress: Int)

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

ContentRecommendation.Builder!

Sets the running time (when applicable) for the content.

ContentRecommendation.Builder!
setSortKey(@Nullable sortKey: String?)

Sets the String sort key for the recommendation.

ContentRecommendation.Builder!
setSourceName(@Nullable source: String?)

Sets the source application name for the recommendation.

ContentRecommendation.Builder!
setStatus(contentStatus: Int)

Sets the availability status for the content.

ContentRecommendation.Builder!
setText(@Nullable description: String?)

Sets the description text for the recommendation.

ContentRecommendation.Builder!
setTitle(title: String!)

Sets the content title for the recommendation.

Public constructors

<init>

Builder()

Constructs a new Builder.

Public methods

build

fun build(): ContentRecommendation!

Combine all of the options that have been set and return a new ContentRecommendation object.

setAutoDismiss

fun setAutoDismiss(autoDismiss: Boolean): ContentRecommendation.Builder!

Sets the flag indicating if the 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.