Skip to main content
Samsung Developer Program

Sending Android Notifications to a Remote Device

Android™ apps can send Android notifications to connected remote devices either via the device Gear Manager (which is independent of RN) or via the RN Manager.

For both methods, on the Android app's device in the Gear Manager, the Android app MUST be checkmarked to send its received Android notifications to the connected remote device. All Android notifications received by the device, either generated by the Android app itself or by another app, that the Android app listens for will be sent to the remote device and can be processed as described in this document.

Via Gear Manager

When configured in the Gear Manager on the Android app's device:

  • Android notifications are sent to the connected remote device independently of the RN Service.
  • RN Manager does not manage the Android notifications, on either the Android or remote device.
  • The end-user manages the Android notifications outside RN, on both the Android and remote device.

To send Android notifications via the Gear Manager, use Android methods.

Via RN Manager

The RN API provides 2 methods to send Android notifications to remoted devices via the RN service. Both methods allow the user to manage the Android notifications in the same way they manage rich notifications, from either their Gear or Android device. The methods differ in whether or not automatic, synchronized processing on both devices is performed on the Android notifications.

  • setRouteCondition()   Sends Android notifications via RN without synchronized processing.
    • From their Gear or Android device, the user can read or delete an Android notification via the RN Manager (in the same way that they read or delete rich notifications).
    • However, the RN Manager on the OTHER device is NOT notified of read and delete actions.
    • The Android app must manage device synchronization of the sent Android notifications.
  • setAssociatedAndroidNotification() Sends Android notifications via RN with synchronized processing.
    • From their Gear or Android device, the user can read or delete an Android notification via the RN Manager (in the same way that they read or delete rich notifications).
    • The RN Manager on the other device is notified of read actions, which enables the Android app / RN Manager on the other device to determine the status and act on it.
    • On the other device, the RN Manager is notified of delete actions and automatically deletes its copy of the sent Android notification, which enables the Android app / RN Manager on the other device to determine the status and act on it.

Sending Android Notifications without Synchronization

Your Android app can send Android notifications that it receives to the connected remote device without synchronized notification processing of the Android and Gear devices. 

SrnRichNotificationManager

setRouteCondition()

Sends the specified Android notification to the connected remote device via the RN Manager.

androidNotification

Declared name of the Android notification to be sent.

To send an Android notification to a remote device without synchronization:

...
NotificationManagermNotificationManager =(NotificationManager)
                                        getSystemService(Context.NOTIFICATION_SERVICE);

NotificationCompat.BuildermBuilder =
    new NotificationCompat.Builder(this)
    .setSmallIcon(R.drawable.notification_icon)
    .setContentTitle("My notification")
    .setContentText("Hello World!");

Notification myAndroidNotification = mBuilder.build();

SrnRichNotificationManager.setRouteCondition(myAndroidNotification);
mNotificationManager.notify(mId, myAndroidNotification);

Sending Android Notifications with Synchronization

Your Android app can send Android notifications that it receives to the connected remote device via RN with synchronized notification processing by both the Android and Gear devices.

The user can manage sent Android notifications on either their Gear or Android device. After the user initially opens the notification on either device, the notification read status is updated in the RN Manager of both devices. After the user deletes the notification on either device, the notification is deleted on the other device, and the notification delete status is updated on both devices.

srnRichNotification

setAssociatedAndroidNotification
(id)

Sends the specified Android notification to the connected remote device via RN and synchronizes read and delete processing of the notification on both the Android and remote devices.

id

Identifying value (positive integer) of the Android notification.

setAssociatedAndroidNotification
(id, tag)

Sends the specified Android notification and its tag to the connected remote device via RN and synchronizes read and delete processing of the notification on both the Android and remote devices.

id

tag

Identifying value (positive integer) of the Android notification.

Tag field (string) of the Android notification.

To send an Android notification to a remote device with synchronization (Android ID):

...
NotificationManagernotificationManager =(NotificationManager)    
    getSystemService(Context.NOTIFICATION_SERVICE);

NotificationCompat.BuildermBuilder =
    new NotificationCompat.Builder(this)
    .setSmallIcon(R.drawable.notification_icon)
    .setContentTitle("My notification")
    .setContentText("Hello World!");

Notification myAndroidNotification = mBuilder.build();
notificationManager.notify(mId, myAndroidNotification);
SrnRichNotificationmyRichNotification = new SrnRichNotification(context);

...

myRichNotification.setAssociatedAndroidNotification(mId);
richNotificationManager.notify(myRichNotification);

To send an Android notification to a remote device with synchronization (Android ID and tag):

...
 
NotificationManagernotificationManager =(NotificationManager)    getSystemService(Context.NOTIFICATION_SERVICE);
 
NotificationCompat.BuildermBuilder =
   new NotificationCompat.Builder(this)
   .setSmallIcon(R.drawable.notification_icon)
   .setContentTitle("My notification")
   .setContentText("Hello World!");
 
Notification myAndroidNotification = mBuilder.build();
notificationManager.notify(notificationId , myAndroidNotification);
SrnRichNotificationmyRichNotification = new SrnRichNotification(context);
 
...
 
myRichNotification.setAssociatedAndroidNotification(notificationId, notificationTag);
richNotificationManager.notify(myRichNotification);

 

  • Was this article helpful?