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 Primary Section

 

Your Android™ app must specify one of the available primary sections to be used in a rich notification:

  • Small, medium, or large header section (with a smaller-to-larger image section and a larger-to-smaller text section).
  • Full-screen header section (with a full-screen image and text overlaid in front).
  • QR (Image) section (with a graphic image, such as a QR code image).

The primary section is defined by methods from three RN classes: the SrnStandardTemplate, SrnPrimaryTemplate, and the SrnImageAsset classes.

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

  • All primary sections: the SrnPrimaryTemplate, SrnStandardTemplate, SrnImageAsset, and SrnStandardTemplate.HeaderSizeType classes.
  • Primary section classes depending on the primary RN template used: SrnQRTemplate, SrnLargeHeaderTemplate.

 

Small, Medium, and Full-screen Header Primary Sections

These constructors and methods are used to create and specify a primary section in the rich notification with a small, medium, or full-screen header area with a background graphic image. The primary section outside the header area can specify a background solid color. The primary section can include subheader and body text, either below the header (small and medium headers) or the text is in front of the header (full-screen header). Subheader and body text is displayed in front of and can extend below the header area. 

Small,Medium, and Full-screen Header Primary Section UI Screen Elements

 

SrnPrimaryTemplate

setBackgroundColor()

Specifies the solid background color of the primary section.

backgroundColor()

Value of the solid color:

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

The default background color is black (0, 0, 0). If a background image is set, the background color will not be displayed.

setBackgroundImage()

Specifies the background image of the header area.

backgroundImage

Name of the background image asset.                                                                                    

When the background image is not set, the header area will be the background solid color of the primary section.
SrnStandardTemplate

SrnStandardTemplate               

Creates an instance of the SrnStandardTemplate used to specify a primary section with a small header area.

SrnStandardTemplate(headerSize)

Creates an instance of the SrnStandardTemplate used to specify a primary section with the specified header area size.

headerSize

     HeaderSizeType.FULL_SCREEN

     HeaderSizeType.MEDIUM

     HeaderSizeType.SMALL

Header size enum type, for example:

     The header color or image is the background of the entire display.    

     The header color or image is the background of a larger top part of the display.        

     The header color or image is the background of a smaller top part of the display.

setHeaderSize()

Specifies the size of the header area, which will contain either the background image or color.

FULL_SCREEN

MEDIUM

SMALL

The header area is the entire initial UI screen.

The header area is the larger top part of the initial UI screen.

The header area is the smaller top part of the initial UI screen.

This setting overrides the instantiated header size setting.

setSubHeader()

Sets the specified sub-title text of the primary section.

subHeader Text string.

setBody()

Sets the specified the body text of the primary section.

body Text string.

 

SrnStandardTemplate.HeaderSizeType

valueOf()

Returns the enum constant of the specified type. 

name

Name of the enum constant type.

The string must exactly match the identifier used to declare an enum constant in this type. Extraneous whitespace characters are not permitted.

values()

Returns an array containing the enum constants of the header size types (SMALL_TEMPLATE_NAME, MEIDUM_TEMPLATE_NAME, and/or FULL_TEMPLATE_NAME) in the order that they were declared.

The method may be used to iterate over the constants as follows:

for (SrnStandardTemplate.HeaderSizeType c :
          SrnStandardTemplate.HeaderSizeType.values())
 System.out.println(c);

 

To specify a full-screen header primary section with a background image:

public SrnPrimaryTemplate myPrimarySection() {
 SrnStandardTemplate standardTemplate = new SrnStandardTemplate(
 HeaderSizeType.FULL_SCREEN);
 Bitmap sectionBackgroundImage = BitmapFactory.decodeResource(context.getResources(), R.drawable.stormy_weather);
 SrnImageAsset sectionBgImage = new SrnImageAsset(context, "section_background_image", sectionBackgroundImage);

 standardTemplate.setBackgroundImage(sectionBgImage);

 standardTemplate.setSubHeader("<b> New Movie Release </b>");
 standardTemplate.setBody("<b>Bulle Netall</b>'s new movie <b><i>The Travelling Musician</i></b>");

 return standardTemplate;
}

 

To specify a medium header primary section with a background image:

public SrnPrimaryTemplate myPrimarySection() {
 SrnStandardTemplate standardTemplate = new SrnStandardTemplate(HeaderSizeType.MEDIUM);

 Bitmap bgBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.stormy_weather);
 SrnImageAsset bgHeaderImage = new SrnImageAsset(mContext, "background_header_image", bgBitmap);

 standardTemplate.setBackgroundImage(bgHeaderImage);

 standardTemplate.setSubHeader("<b> New Book Release </b>");
 standardTemplate.setBody("<b>Eric Reed</b>'s new book <i>Flying Mystery and Magic</i> has just been released");

 return standardTemplate;
}

 

To specify a small header primary section with a background color:

public SrnPrimaryTemplate myPrimarySection() {
 SrnStandardTemplate standardTemplate = new SrnStandardTemplate(HeaderSizeType.SMALL);

 standardTemplate.setSubHeader("<b> New Album Release </b>");
 standardTemplate.setBody("<b>Danny Banjo</b>'s New Album <b>More of the Same</b> released");

 standardTemplate.setBackgroundColor(Color.rgb(0, 0, 255));

 return standardTemplate;
}

 

Large Header Primary Section

These constructors and methods are used to create and specify a primary section in the rich notification with a large header (either a solid color or a graphic image) only. 

Large Header Primary Section UI Screen Elements

 

SrnLargeHeaderTemplate

SrnLargeHeaderTemplate  

Creates an instance of the SrnLargeHeaderTemplate used to specify a primary section with a large header size.

 

SrnPrimaryTemplate

setBackgroundColor()

Specifies the solid background color of the primary section.

backgroundColor

Value of the solid color:

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

The default background color is black (0, 0, 0). If a background image is set, the background color will not be displayed.

setBackgroundImage()

Specifies the background image of the header area.

backgroundImage

Name of the background image asset.

When the background image is not set, the header area will be the background solid color of the primary section.
 

To specify a large header primary section with a background image:

public SrnPrimaryTemplate myPrimarySection() {
 SrnLargeHeaderTemplate largeHeaderTemplate = new SrnLargeHeaderTemplate();

 Bitmap bgBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.stormy_weather);
 SrnImageAsset bgHeaderImage = new SrnImageAsset(mContext, "background_header_image", bgBitmap);

 largeHeaderTemplate.setBackgroundImage(bgHeaderImage);

 return largeHeaderTemplate;
}

To specify a large header primary section with a background color:

public SrnPrimaryTemplate myPrimarySection() {
 SrnLargeHeaderTemplate largeHeaderTemplate = new SrnLargeHeaderTemplate();

 largeHeaderTemplate.setBackgroundColor(Color.rgb(0, 0, 255));

 return largeHeaderTemplate;
}

QR (Image) Primary Section

These constructors and methods are used to create and specify a primary section in the rich notification with a small image (such as a QR code or other graphic image). The primary section background can be either a solid color or a graphic image. The primary section can include subheader text below the small image. 

QR (Image) Primary Section  UI Screen Elements

 

SrnPrimaryTemplate

setBackgroundColor()

Specifies the solid background color of the primary section.

backgroundColor

Value of the solid color:

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

The default background color is black (0, 0, 0). If a background image is set, the background color will not be displayed.

setBackgroundImage()

Specifies the background image of the primary RN section.

backgroundImage

Name of the background image asset.

When the background image is not set, the primary section background will be a solid color.

 

SrnQRTemplate

SrnQRTemplate           

Creates an instance of the SrnQRTemplate used to specify the primary QR (image) section.

setImage()

Specifies the small image (such as a QR code or graphic image) in the primary section.

image Name of the small image asset.

setSubHeader()

Specifies the subtitle text in the primary section.

subHeader Text of the section subtitle.

 

To specify a QR (image) primary section with a background color:

public SrnPrimaryTemplate myPrimarySection() {
 SrnQRTemplate qrTemplate = new SrnQRTemplate(); 
 
 qrTemplate.setBackgroundColor(Color.rgb(0,0,255));
 
 Bitmap sectionImageBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.qr_code_image);
 
 SrnImageAsset sectionImageAsset = new SrnImageAsset(context, "section_image", sectionImageBitmap);
 
 qrTemplate.setImage(sectionImageAsset);

 qrTemplate.setSubHeader("<b> Sweetheart Competition Roses </b>");

 return qrTemplate;

 

To specify a QR (image) primary section with a background image:

public SrnPrimaryTemplate myPrimarySection() {
 SrnQRTemplate qrTemplate = new SrnQRTemplate();

 Bitmap sectionBackgroundImage = BitmapFactory.decodeResource(context.getResources(), R.drawable.rose_image);
 SrnImageAsset sectionBgImage = new SrnImageAsset(context, "section_background_image", sectionBackgroundImage);

 qrTemplate.setBackgroundImage(sectionBgImage);

 Bitmap sectionImageBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.qr_code_image);
 SrnImageAsset sectionImageAsset = new SrnImageAsset(context, "section_image", sectionImageBitmap);
 qrTemplate.setImage(sectionImageAsset);

 qrTemplate.setSubHeader("<b> Sweetheart Competition Roses </b>");

 return qrTemplate;

 

  • Was this article helpful?