Skip to main content
Samsung Developer Program

Managing Rich Notification Callbacks

Your activity or service can implement the SrnRichNotificationManager.EventListener interface to get callbacks from the Rich Notification Service.

After implementing the interface, that class must be registered with the SrnRichNotificationManager.

Note: Because up to 50 rich notifications per RN Android app can persist on a Gear device, it is recommended to persistently store each notification’s UUID on the Android device to ensure they remain upon Android device reboot. Filtering the received UUIDs against stored ones increases the security of components.

SrnRichNotificationManager

SrnRichNotificationManager
.EventListener

Interface is used to notify a third-party Android™ app about the information regarding rich notifications.

registerRichNotificationListener()

Adds the specified SrnRichNotificationManager.EventListener to receive a callback.

 

listener

Event listener to be registered.

unregisterRichNotificationListener()

Removes the specified SrnRichNotificationManager.EventListener from registration.

 

listener

Event listener to be unregistered.

showErrorToast()             

Sends a request to display the specified error toast for an SrnRichNotification to inform the user when an SrnAction failed or could not be completed.

 

uuid

errorMessage

Universal Unique IDentifier of the rich notification.

Toast text to be displayed.

SrnRichNotificationManager.EventListener

onRemoved()

Causes Android app to receive information (rich notification UUID and deletion notification) via an event listener after the Gear device user deletes (dismisses) the specified rich notification.
 

uuid

Universal Unique IDentifier of the rich notification.

onRead()

Notifies the Android app via a listener callback when the Gear device user first opens the specified rich notification (via the receipt or summary RN UI screens, or via the Rich Notification Manager).

 

uuid

Universal Unique IDentifier of the rich notification.

 

The Android app is only notified after the user initially opening the rich notification. Subsequent openings do not trigger notification.

onError()

Notifies the Android app via listener callback when the specified rich notification has been removed AND the specified error has occurred.

 

uuid

error

Universal Unique IDentifier of the removed rich notification.

Value (type) of identifying value of the error.
UNDEFINED is currently the only supported error setting for this parameter.

To implement an event listener for a rich notification:

MyActivity extends Activity implements
                                        SrnRichNotificationmManager.EventListener{

public void onRemoved(UUID uuid) {
    // Called when the UUID rich notification has been deleted (dismissed).
}
public void onRead(UUID uuid) {
    // Called when the UUID rich notification has been opened by the user.
}
public abstract void onError(UUID uuid, ErrorEnum error) {
    // Called when the specified error occurs when processing the UUID rich
    // notification. For example, if an action fails to be taken on a remote
    // device for some reason.
}

public void myRegisterFunction()
{
...
richNotificationManager.registerRichNotificationListener(myActivity);
...
}
}

To unregister an event listener:

richNotificationManager.unregisterRichNotificationListener(myActivity);

 

  • Was this article helpful?