ContentRecommendation.Builder

public static final class ContentRecommendation.Builder
extends Object

java.lang.Object
   ↳ 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

Builder()

Constructs a new Builder.

Public methods

ContentRecommendation build()

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

ContentRecommendation.Builder setAutoDismiss(boolean autoDismiss)

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

ContentRecommendation.Builder setBackgroundImageUri(String imageUri)

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

ContentRecommendation.Builder setBadgeIcon(int iconResourceId)

Sets the resource ID for the recommendation badging icon.

ContentRecommendation.Builder setColor(int color)

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

ContentRecommendation.Builder setContentImage(Bitmap image)

Sets the recommendation image.

ContentRecommendation.Builder setContentIntentData(int intentType, Intent intent, int requestCode, Bundle options)

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

ContentRecommendation.Builder setContentTypes(String[] types)

Sets the content types associated with the content recommendation.

ContentRecommendation.Builder setDismissIntentData(int intentType, Intent intent, int requestCode, Bundle options)

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(String[] genres)

Sets the content genres for the recommendation.