How to automatically close RichNotification when clicking its icon in Samsung Accessory Library?

Original Created Jun 22, 2016 | Regeneration Apr 22, 2026

I'm using RichNotification from Samsung Accessory Library to send notifications from an Android phone to Gear S2. When the user taps the notification icon, it successfully launches a Tizen app on the Gear S2. However, the notification remains visible even after the app launches.

How can I make the notification automatically close when the user taps its icon? Below is my Android code implementation:

mRichNotificationManager = new SrnRichNotificationManager(getApplicationContext());
mRichNotificationManager.start();

SrnRichNotification myRichNotification = new SrnRichNotification(this);
Bitmap myAppIconBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
SrnImageAsset myAppIcon = new SrnImageAsset(this, "app_icon", myAppIconBitmap);
myRichNotification.setIcon(myAppIcon);
myRichNotification.setTitle("Raptors vs. Nets");

SrnStandardTemplate myPrimaryTemplate = new SrnStandardTemplate(SrnStandardTemplate.HeaderSizeType.MEDIUM);
myRichNotification.setPrimaryTemplate(myPrimaryTemplate);

SrnRemoteLaunchAction myAction = new SrnRemoteLaunchAction("Check In");
Bitmap checkInIconBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.listen);
SrnImageAsset checkInIcon = new SrnImageAsset(this, "checkin_icon", checkInIconBitmap);
myAction.setIcon(checkInIcon);

myAction.setPackage("org.example.multiview");
Bundle bundle = new Bundle();
bundle.putString("message","data from phone");
myAction.setExtras(bundle);

myRichNotification.addActionWithPermissionCheck(myAction);
myRichNotification.setAlertType(SrnRichNotification.AlertType.SOUND_AND_VIBRATION, SrnRichNotification.PopupType.NORMAL);
mRichNotificationManager.notify(myRichNotification);
mRichNotificationManager.stop();

Problem Understanding

The issue occurs when using Samsung Accessory Library's RichNotification feature. While the notification successfully triggers the Tizen app launch on Gear S2, the notification persists rather than automatically closing after the app launch.

Solution Methods

  1. Using dismissAll() method:

    • Call dismissAll() before stopping the notification manager
    • This method dismisses all active rich notifications
    • Implementation:
      mRichNotificationManager.notify(myRichNotification);
      mRichNotificationManager.dismissAll();
      mRichNotificationManager.stop();
      
  2. Alternative approach:

    • Implement a callback mechanism in your Tizen app
    • When the app launches, send a signal back to the Android device
    • Have the Android device dismiss the specific notification upon receiving this signal

Code Examples

Here's the corrected implementation for automatic dismissal:

// After setting up your notification
mRichNotificationManager.notify(myRichNotification);

// Add dismissAll() before stopping the manager
mRichNotificationManager.dismissAll();
mRichNotificationManager.stop();

Additional Tips

  • Ensure your notification has a unique ID if you're managing multiple notifications
  • Test the notification flow thoroughly as timing issues might affect dismissal
  • Consider implementing error handling for cases where the notification might fail to dismiss
  • For more complex scenarios, you might need to implement a custom notification dismissal protocol between your Android and Tizen apps

Customize your cookie preferences

You can enable or disable non-essential cookies. Essential cookies are always on to ensure the site works properly and to keep you signed in.

Necessary

These cookies are necessary for the website to function properly and cannot be switched off. They help with things like logging in and setting your privacy preferences.

Always on

Analytics

These cookies help us improve the site by tracking which pages are most popular and how visitors move around the site.

Enable analytics cookies
Public Forum Public Forum
Employees only. Please sign in with your company account.