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

Checking the Android and Gear Device Connection

 

After creating a rich notification, it is recommended to check whether the Gear device is connected to the Android™ device before posting the rich notification to the RN Manager, which manages the sending of rich notifications.

isConnected() returns the current connection status.  Your Android app can use broadcast filtering (via DEVICE_STATE_CHANGED) to be notified of changes to Android / Gear device connection status.

SrnRichNotificationManager

isConnected()

Gets the current connection status of a Gear device.

Returns:

True when a Gear device is connected to the Android device. Otherwise, false.

 

To get the current Android / Gear device connection status and to be notified of changes to the status:

// AndroidManifest.xml
<receiver android:name=".MyBroadcastReceiver" >
<intent-filter>
<action android:name="com.samsung.wmanager.rich_notification.DEVICE_STATE_CHANGED" />
</intent-filter>
</receiver>
 
// MyBroadcastReceiver.java
public void onReceive(Context context, Intent intent) {
    boolean isConnected = intent.getBooleanExtra("isConnected", false);
       if (isConnected) {
       ...
    }
}

 

  • Was this article helpful?