@Override
  public void onReceive(Context context, Intent intent) {
    int notificationId = intent.getIntExtra("notificationId", 0);
    if (notificationId == GCMIntentService.GROUP_NOTIFICATION_ID) {
      GCMIntentService.clearNotifications();
    } else {
      GCMIntentService.removeNotification(notificationId);

      // Dismiss the grouped notification if a user dismisses all notifications from a wear device
      if (!GCMIntentService.hasNotifications()) {
        NotificationManager notificationManager =
            (NotificationManager) context.getSystemService(GCMIntentService.NOTIFICATION_SERVICE);
        notificationManager.cancel(GCMIntentService.GROUP_NOTIFICATION_ID);
      }
    }
  }