Skip to main content
Samsung Developer Program

Controlling the Base Section and Fundamental RN Aspects

Your Android™ app can create a new rich notification and can update a previously posted rich notification. When an updated rich notification is posted before its previous rich notification has been sent, the previous rich notification will be sent before or at the same time the update is sent.

Your Android app:

  • Must create the rich notification.
  • Must specify a primary section and can optionally declare a secondary section for the rich notification.
  • Can specify the title and icon of the notification.
  • Can optionally specify the sender app icon and spoken text and/or notification alert announcements of the rich notification upon receipt by the Gear device.
  • Can optionally specify that a button action in the rich notification undergo a permission check (for Call / SMS).
SrnRichNotification

SrnRichNotification(context)

Creates a new rich notification from the specified context.

context

Context from which the rich notification is to be created.

SrnRichNotification(context, UUID)

Creates an update rich notification to the specified previously posted rich notification from the specified context.

context

uuid

Context from which the update rich notification is to be created.

Universally Unique IDentifier of the previous rich notification.

To create a new rich notification:

SrnRichNotification myRichNotification = new SrnRichNotification(mContext);

To create an update rich notification:

SrnRichNotification myUpdateRichNotification = new SrnRichNotification(mContext,
                                                              prevRichNotificationUuid);
​SrnRichNotification

setPrimaryTemplate()

Required  Specifies the primary section to be included in the rich notification, which is defined in SrnPrimaryTemplate.

template

Name of the primary section.

SrnRichNotification(context, UUID)

Optional  Specifies the secondary section to be included in the rich notification, which is defined in SrnSecondaryTemplate.

template

Name of the secondary section.

To include primary and secondary sections in a rich notification:

myRichNotification.setPrimaryTemplate(myPrimarySection());
myRichNotification.setSecondaryTemplate(mySecondarySection());
​SrnRichNotification

setIcon()

Specifies the icon image to be associated with the rich notification.

icon

Name of the declared SrnImageAsset image.

While the icon is specific to the notification, the icon can be associated with other purposes. For example, the icon can identify the sender app or the category of notification (daily, weekly, news, and politics).

When the notification icon is NOT specified, the sender app icon specified in the Android manifest file is used instead of the notification icon.  When the notification and sender app icon are both not specified, the default Android app icon is used.

setReadout()

For Gear devices that support text-to-speech, the specified title and readout text to be rendered audibly.

title

readout

Text string to be read out first.

Text string to be read out second.

setAlertType(alertType)

 

Specifies the type of alert to be activated when the Gear device supports the alert type and receives the rich notification.

AlertType.

Sound and/or action:

SILENCE

VIBRATION

SOUND

SOUND_AND_VIBRATION

Sound and/or action:

No sound / no shaking

Shaking / no sound

Sound / no shaking

Sound / shaking

Not specifying setAlertType() results in no device or UI display action upon notification receipt.

setAlertType(alertType, popupType)

 

Specifies the type of alert and/or popup to be activated when the Gear device supports the alert type and receives the rich notification.

AlertType

Sound and/or action:

SILENCE

VIBRATION

SOUND

SOUND_AND_VIBRATION

Sound and/or action:

No sound / no shaking

Shaking / no sound

Sound / no shaking

Sound / shaking

PopupType

Whether to momentarily display
a popup with sender app icon
and notification title: 

NONE

NORMAL

 

 

Default Display the popup

Display the popup

Not specifying setAlertType() results in no device or UI display action when the Gear device receives the rich notification.

addAction()

 

Includes the specified RN action in the rich notification.

action Declared name of the action object to be included.

The first added action is the primary action. All other added actions are secondary actions indexed in the adding order.

Note: It is recommended to use addActionWithPermissionCheck() instead of this method.

addActions()

 

Includes 1 or more RN actions in the specified list in the rich notification.

actions Declared name of the list of actions to be included.

The first declared action is the primary action. All other declared actions are secondary actions indexed in the order of declaration.

Note: It is recommended to use addActionsWithPermissionCheck() instead of this method.

addActionWithPermissionCheck()

 

Includes the specified RN action in the rich notification after checking for the appropriate permission.

action Declared name of the action object to be included.

The first added action is the primary action. All other added actions are secondary actions indexed in the adding order.

addActionsWithPermissionCheck()

 

Includes 1 or more RN actions in the specified list in the rich notification after checking each action for the appropriate permission.

actions Declared name of the list of actions to be included.

The first declared action is the primary action. All other declared actions are secondary actions indexed in the order of declaration.

​SrnRichNotification.AlertType

valueOf()

Returns the enum constant of the specified alert type. 

name

Name of the enum constant alert type 
(SILENCE, VIBRATION, SOUND, or SOUND_AND_VIBRATION).

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

values()

Returns an array containing the enum constants of the alert types (SILENCE, VIBRATION, SOUND, and/or SOUND_AND_VIBRATION) in the order that they were declared.

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

for (SrnRichNotification.AlertType c :                           
                    SrnRichNotification.AlertType.values())
 System.out.println(c);

​SrnRichNotification.PopupType

valueOf()

Returns the enum constant of the specified popup type. 

name

Name of the enum constant popup type (NORMAL or NONE).

The string must exactly match the identifier used to declare an enum constant of the popup types. Extraneous white space characters are not permitted.

values()

Returns an array containing the enum constants of the popup enum types (NORMAL and NONE) in the order that they were declared.

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

for (SrnRichNotification.PopupType c :                           
                    SrnRichNotification.PopupType.values())
 System.out.println(c);

​SrnRichNotification.ErrorType

valueOf()

Returns the enum constant of the specified error type. 

name

Name of the enum constant error type (UNDEFINED).

The string must exactly match the identifier used to declare an enum constant in the error types. Extraneous white space characters are not permitted.

values()

Returns an array containing the enum constants of the error type UNDEFINED in the order that they were declared.

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

for (SrnRichNotification.ErrorType c :                           
                    SrnRichNotification.ErrorType.values())
 System.out.println(c);

To set base section elements of a rich notification:

public class LargeHeaderExample implements IExample {

    private final Context mContext;

    public LargeHeaderExample(Context ctx) {
        mContext = ctx;
    }

    @Override
    public SrnRichNotification createMyRichNotification() {
        SrnRichNotification myRichNotification = new SrnRichNotification(mContext);
        myRichNotification.setReadout("Today's Weather", "40 percent chance light rain");

        myRichNotification.setPrimaryTemplate(myPrimarySection());

        myRichNotification.setSecondaryTemplate(mySecondarySection());
 
        try{
        myRichNotification.addActionsWithPermissionCheck(myActionList());
         } catch(Exception e)
         {
           e.printStackTrace(); 
         }

        myRichNotification.setAlertType(AlertType.SOUND_AND_VIBRATION,
                                                      SrnRichNotification.PopupType.NORMAL);

        Bitmap notificationIconBitmap =
                                   BitmapFactory.decodeResource(mContext.getResources(),
                                   R.drawable.rain_icon);
        SrnImageAsset notificationIcon = new SrnImageAsset(mContext,
                                              "notification_icon", notificationIconBitmap);
        myRichNotification.setIcon(notificationIcon);

        myRichNotification.setTitle("" +
                "Today's Weather");

        return myRichNotification;
    }

 

  • Was this article helpful?