Skip to main content

Ready to market your stellar app?

Samsung Developer Program is your gateway to app monetization success.

Learn More

Samsung Developer Program

Controlling the Secondary Section

 

Your Android™ app can optionally specify one of the available secondary sections to be used in a rich notification:

  • Standard secondary section (title, subheader, body, list items and images, and small icon and text).
  • QR (Image) section (list items and images, and small icon and text).

The secondary section is defined by methods in the following classes:

  • All secondary sections: the SrnSecondaryTemplate, SrnStandardSecondaryTemplate, SrnImageAsset, and SrnStandardTemplate.HeaderSizeType classes.
  • Secondary section classes depending on the secondary RN template used: SrnQRSecondaryTemplate, SrnLargeHeaderTemplate.

 

Standard Secondary Section

Constructors and methods are used to specify a standard secondary section in a rich notification with a solid background color and a graphic image.  Outside the header area can include a solid background color, and a title, subheader, body text, and one or two small icon lines (with an icon and text). 

Standard Secondary Section Section UI Screen Elements

Figure: Standard Secondary Section UI Screen Elements

SrnSecondaryTemplate

setBackgroundColor()

Specifies the solid background color of the secondary section.

backgroundColor

Value of the solid color:

Color.rgb([r, g, b values])

The default background color is black (0, 0, 0).

 

SrnStandardSecondaryTemplate

SrnStandardSecondaryTemplate        

Creates an SrnStandardSecondaryTemplate object used to specify the standard secondary section.

setImage()

Specifies a small image in the secondary section.

image Name of the small image asset.

setSmallIcon1()

Specifies the image and title text of the first small icon in the secondary section.

smallIcon

smallIconTitle

Name of the small icon image asset.

Text of the small icon title.

setSmallIcon2()

Specifies the image and title text of the second small icon in the secondary section.

smallIcon

smallIconTitle

Name of the small icon image asset.

Text of the small icon title.

setTitle()

Specifies the title text of the secondary section.
title Text of the section's title.

setSubHeader()

Specifies the subtitle text of the secondary section.

subHeader Text of the section subtitle.

setBody()

Specifies the body text of the secondary section.

body Text of the section body.

 

To specify a standard secondary section:

public SrnSecondaryTemplate mySecondarySection() {
    SrnStandardSecondaryTemplate standardSecondaryTemplate = new
                                                            SrnStandardSecondaryTemplate();

    standardSecondaryTemplate.setTitle("<b>Weather Summary</b>");
    Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();

    standardSecondaryTemplate.setSubHeader("<b>Today's Date</b>:" + today.year + "/"
                                                     + today.month + "/" + today.monthDay);

    standardSecondaryTemplate.setBody("<b>40% Chance of Light Rain</b>: In the morning,"
     + "a low of 56 degrees.  In the early afternoon, mostly cloudy and warming "
     + "to 61 degrees.  In the late afternoon, mostly cloudy with sunset at 5:20 pm. "
     + "Before midnight, clearing and cooling.  After midnight, clear with a low of 44.");

    standardSecondaryTemplate.setBackgroundColor(Color.rgb(0, 0, 127));

    Bitmap sectionImageBitmap = BitmapFactory.decodeResource(mContext.getResources(),
                                                                  R.drawable.cloud_graphic);
    SrnImageAsset sectionImage = new SrnImageAsset(mContext, "section_image",
                                                                        sectionImageBitmap);
    standardSecondaryTemplate.setImage(sectionImage);

    Bitmap icon1Bitmap = BitmapFactory.decodeResource(mContext.getResources(),
            R.drawable.star_gold_icon);
    SrnImageAsset icon1Image = new SrnImageAsset(mContext, "comment_icon",
                                                                              icon1Bitmap);
    standardSecondaryTemplate.setSmallIcon1(icon1Image, "4/5");

    Bitmap icon2Bitmap = BitmapFactory.decodeResource(mContext.getResources(),
                                                                R.drawable.thumbs_up_icon);
    SrnImageAsset icon2Image = new SrnImageAsset(mContext, "like_icon", icon2Bitmap);
    standardSecondaryTemplate.setSmallIcon2(icon2Image, "389+");

    return standardSecondaryTemplate;
}

 

QR (Image) Secondary Section

Constructors and methods are used to create and specify a QR (image) secondary section in a rich notification with a solid background color and the graphic image (which can be a QR code or any other image). The section background can be a specified solid color or the default color (black). The section can include one or more list items (title and body text), and one or two small icon lines (with an icon and text). 

QR (Image) Secondary Section Section UI Screen Elements

Figure: QR Secondary Section UI Screen Elements

SrnSecondaryTemplate

setBackgroundColor()

Specifies the solid background color of the secondary section.

backgroundColor

Value of the solid color:

Color.rgb([r, g, b values]) 

The default background color is black (0, 0, 0).

 

SrnQRSecondaryTemplate

SrnQRSecondaryTemplate        

Creates an SrnQRSecondaryTemplate object used to specify the standard secondary section.

addListItem()

Adds the specified title and body of one item, typically in a list of multiple items, in the secondary section.

listTitle

listBody 

Text of the item's title (such as "Profession:").

Text of the item's body (such as "Doctor").

setImage()

Specifies the small image in the secondary section.

image

Name of the small image asset.

setSmallIcon1()

Specifies the image and title text of the first small icon in the secondary section.

smallIcon

smallIconTitle

Name of the small icon image asset.

Text of the small icon title.

setSmallIcon2()

Specifies the image and title text of the second small icon in the secondary section.

smallIcon

smallIconTitle

Name of the small icon image asset.

Text of the small icon title.

 

To specify a QR (image) secondary section:

public SrnSecondaryTemplate mySecondarySection() {
 SrnQRSecondaryTemplate qrSecondaryTemplate = new SrnQRSecondaryTemplate();

 qrSecondaryTemplate.setBackgroundColor(Color.rgb(0, 0, 127));

 Bitmap qrCodeBitmap = BitmapFactory.decodeResource(context.getResources(), 
                                                                  R.drawable.qr_code_image);
 SrnImageAsset qrCodeImage = new SrnImageAsset(context, "qr_code_big", 
                                                                                qrCodeBitmap);
 qrSecondaryTemplate.setImage(qrCodeImage);

 qrSecondaryTemplate.addListItem("Country of Origin", "Holland");
 qrSecondaryTemplate.addListItem("Product", "Competition Qualified Rose");
 qrSecondaryTemplate.addListItem("Shipping", "Overnight");
 qrSecondaryTemplate.addListItem("Color", "Overnight");

 Bitmap commentBitmap = BitmapFactory.decodeResource(context.getResources(),
                                     R.drawable.star_gold_icon);
 SrnImageAsset commentIcon = new SrnImageAsset(context, "comment_icon", 
                                                                          commentBitmap);
 qrSecondaryTemplate.setSmallIcon1(commentIcon, "A+");

 Bitmap likeBitmap = BitmapFactory.decodeResource(context.getResources(), 
                                                            R.drawable.thumbs_up_icon);
 SrnImageAsset likeIcon = new SrnImageAsset(context, "like_icon", likeBitmap);
 qrSecondaryTemplate.setSmallIcon2(likeIcon, "4163+");

 return qrSecondaryTemplate;
}

 

  • Was this article helpful?