MAD Gaze Watch
Android SDK for Watch

MAD Gaze Watch: Android SDK for Watch

v2021.1 (Release Date: 03/02/2021)

  • First Release

    1. Android SDK for Mobile: This SDK allows developer to create their apps on connected mobile phone and control their apps via Watch Gestures.
  • Updates

    1. Android SDK for Watch:
    • Support 25+ Watch Gestures
    • Added API to check if the requested gestures are ready for use (calibrated before).

View historical changes


Build History

Date Watch SDK (Gradle) Demo Project (.zip)
02/03/2021 com.madgaze.smartwatch:development-kit-watch:1.1.0 Download
10/12/2020 com.madgaze.smartwatch:development-kit-watch:1.0.0 Download

Capabilities

Android SDK for Watch provides the following functions:

  • Detect 33 Watch Gestures on MAD Gaze Watch
  • Detect Watch Connection

33 Watch Gestures

Single-handed Gestures

Gestures performed by single hand finger movements, such as snapping.


  • THUMBTAP_INDEX_MIDDLE

  • FINGER_SNAP

  • THUMBTAP_INDEX

  • THUMBTAP_MIDDLE

  • THUMBTAP_INDEX_MIDDLE_2

  • FINGER_SNAP_2

  • THUMBTAP_INDEX_2

  • THUMBTAP_MIDDLE_2

Tap Gestures

Gestures performed by finger tapping on hand, fingers and forearm.


  • FOREARM_LEFT

  • FOREARM_RIGHT

  • HANDBACK_UP

  • HANDBACK_DOWN

  • HANDBACK_LEFT

  • HANDBACK_RIGHT

  • FOREARM_LEFT_2

  • FOREARM_RIGHT_2

  • HANDBACK_UP_2

  • HANDBACK_DOWN_2

  • HANDBACK_LEFT_2

  • HANDBACK_RIGHT_2

  • JOINTTAP_LOWER_THUMB

  • JOINTTAP_UPPER_THUMB

  • JOINTTAP_MIDDLE_INDEX

  • JOINTTAP_UPPER_INDEX

  • JOINTTAP_MIDDLE_MIDDLE

  • JOINTTAP_UPPER_MIDDLE

  • JOINTTAP_MIDDLE_RING

  • JOINTTAP_UPPER_RING

  • JOINTTAP_MIDDLE_LITTLE

Motion Gestures

Arm Movements


  • MOVE_FOREARM_UP

  • MOVE_FOREARM_DOWN

  • MOVE_FOREARM_LEFT

  • MOVE_FOREARM_RIGHT

Project Setup

  1. Complete Personalised Setup Training from MGWatch app (Ignore this if you have already completed.)

  2. Disconnect from Mobile Connection.

    You can disconnect it by pressing Disconnect button from MGWatch app.

    (To check if disconnection was successful, you can check connection status from MAD Gaze Controller on MAD Gaze Watch.)

  3. Open or Create an Android Project

  4. Add the dependencies in app/build.gradle

    implementation 'com.madgaze.smartwatch:development-kit-watch:1.1.0'
    
  5. You can now access all hand gesture feedbacks from MAD Gaze Watch.

*Remark 1: Required version for MAD Gaze Controller: v1.4 (Open MAD Gaze Controller with Wi-Fi)

*Remark 2: Battery saver mode must be turned off on User's Watch (App Menu > Optimization > Clean Task > Turn off Battery Saver mode.


Setup an Activity Class

  1. Create a Blank Activity

  2. Inherits current Activity class from WatchActivity

    public class MainActivity extends WatchActivity {
        ...
    }
    
  3. Create the implementation for the following inherited methods.

Method Description

onMGWatchServiceReady()

Callback invokes when MG Watch Service (which is Preinstalled with MGWatch) is connected.

  • Usually we start the gesture recognition here.
onWatchDetectionOn() Callback invokes when Watch Gesture Recognition is started followed by a successful call of MGWatch.startWatchGestureDetection().
onWatchDetectionOff() Callback invokes when Watch Gesture Recognition is finished followed by a successful call of MGWatch.stopWatchGestureDetection().

getRequiredWatchGestures()

Declare the required Watch Gesture(s) for your application.

  • Developer needs to declare all required gestures in this Activity instance in order to receive gesture callbacks during the recognition.
onWatchGestureReceived(WatchGesture) Callback invokes when a Watch Gesture is recognized.
onWatchGestureError(WatchException) Callback invokes when Watch Recognition or Initialization was unsuccessful.

Declare Required Gestures

In this activity class, developer needs to declare specific Watch Gestures that need to be recognized in this application (Activity Instance).

To declare the required watch gestures, override the inherited method getRequiredWatchGesture() and state the return parameters with required watch gestures in an array object.

public final WatchGesture[] REQUIRED_WATCH_GESTURES = {
    WatchGesture.FINGER_SNAP,
    WatchGesture.FINGER_INDEX_MIDDLE,
    WatchGesture.ARM_LEFT,
    WatchGesture.ARM_LEFT_2,
    WatchGesture.ARM_RIGHT,
    WatchGesture.HANDBACK_UP,
    WatchGesture.FINGER_INDEX,
    WatchGesture.MOVE_ARM_DOWN,
    WatchGesture.FINGER_MIDDLE
};

@Override
protected WatchGesture[] getRequiredWatchGestures(){
    return REQUIRED_WATCH_GESTURES;
}

To check the required gestures are ready to use

Developers can check if the required (declared) gestures are trained before with the following code snippets.

boolean isGesturesReady = MGWatch.isGesturesTrained(ctx);

To force user to train the missing gestures

If any of the required gestures is not trained by users, the recognition will not be able to start.

By using the following API, it will navigate users to MGWatch app and perform the training to required gestures.

MGWatch.trainRequiredGestures(ctx);

Gesture Recognition

To receive the recognition events, override the inherited methods onWatchGesture(WatchGesture) and you will receive the Watch Gestures that you have declared at earlier moments.

@Override
public void onWatchGestureReceived(WatchGesture gesture) {
    //Handling recognized Watch Gestures
}

Start/Stop Gesture Recognition

To start the gesture recognition.

MGWatch.startGestureDetection(this);

Developers shall make sure the the Required Gestures for this application are trained** before starting the gesture recognition.

To stop gesture recognition

To stop the gesture recognition.

MGWatch.stopGestureDetection(this);

Readyness of Required Gestures

To check if all required gestures for this application (declared earlier) are previously trained.

boolean isGesturesReady = MGWatch.isGesturesTrained(ctx);

Developers may notify users to train the required gestures in MGWatch app.


Lifecycle Handling

We should always suspend the recognition when the application is running in background. Override the onResume() and onPause() methods, and insert the handling code snippets for these methods.

@Override
public void onPause(){
    super.onPause();

    if (MGWatch.isWatchGestureDetecting(this))
        MGWatch.stopGestureDetection(this);
}

Watch SDK provides multiple API to handle different scenarios with page redirection such as navigating users to Training page and Connect page of MGWatch app. Developers need to handle the results in onResume() method.

@Override
public void onResume(){
    super.onResume();

    if (MGWatch.isMGWatchServiceReady(this)) {
        if (!MGWatch.isWatchGestureDetecting(this)) {
            //Start recognition.
            MGWatch.startGestureDetection(this);
        }
    }
}

Error Handling

@Override
public void onWatchGestureError(WatchException error) {
    //Handling Watch Gesture Errors
}
WatchException Description
CONTROLLER_APP_NOT_UPDATED MAD Gaze Controller app on the User's Watch is not up-to-date. Please notify user to update the application before using your app.
MGWATCH_SERVICE_DISCONNECTED MG Watch Service is disconnected. This is not an expected behaviour. Please contact MAD Gaze CS Team.
UNABLE_TO_START_INCOMPLETED_TRAINING startGestureDetection() was failed because the declared gestures for this application MAD Gaze Watch are not completely trained.

Changelog

v2021.1 (Release Date: 03/02/2021)

  • First Release

    1. Android SDK for Mobile: This SDK allows developer to create their apps on connected mobile phone and control their apps via Watch Gestures.
  • Updates

    1. Android SDK for Watch:
    • Support 25+ Watch Gestures
    • Added API to check if the requested gestures are ready for use (calibrated before).

v1.0.0 (Release Date: 12/10/2020)

  • First Release
    1. Android SDK for Watch: This SDK allows users to developer their application on MAD Gaze Watch with supported Watch Gestures.

Disclaimer

This library is licensed under the MAD Gaze - Terms of Use.

Copyright © 2021 MAD Gaze. All rights reserved.