MAD Gaze Watch
Android SDK for Mobile

MAD Gaze Watch: Android SDK for Mobile

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

Capabilities

Android SDK for Mobile provides the following functions:

  • Detect 33 Watch Gestures on Connected Phone
  • 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. Install MGWatch from Android Store (Currently, SDK is not available on iOS devices.)

  2. Complete Personalised Setup Training from MGWatch app.

  3. Open existing Android Project or Create a new Android Project.

  4. Add the dependency settings in gradle file app/build.gradle.

    implementation 'com.madgaze.smartwatch:development-kit-watch:1.1.0'
    
  5. Continues on Chapter - Setup an Activity Class.

*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 MobileActivity

    public class MainActivity extends MobileActivity {
        ...
    }
    
  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.
onWatchConnected() Callback invokes when MAD Gaze Watch is connected.

onWatchDisconnected()

Callback invokes when MAD Gaze Watch is disconnected.

  • Developer may notify user to reconnect MAD Gaze Watch via MGWatch app, or redirect user to MGWatch app using MGWatch.connect(ctx) API.
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 1) MAD Gaze Watch is connected and 2) Required Gestures for this application are trained before starting the gesture recognition.

To check if MAD Gaze Watch is already connected to the Mobile Phone.

boolean isWatchConnected = MGWatch.isWatchConnected(this)

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.isWatchConnected(this)) {
            //Watch is not connected. Navigate to Connect page on MGWatch app.
            MGWatch.connect(this);
            return;
        }

        if (!MGWatch.isGesturesTrained(this)) {
            //Some of Required Gestures is not trained. Navigate to Training page on MGWatch app.
            MGWatch.trainRequiredGestures();
            return;
        }

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

Error Handling

@Override
public void onWatchGestureError(WatchException error) {
    //Handling Watch Gesture Errors
}
WatchException Description
MGWATCH_NOT_UPDATED MGWatch app on User's Mobile Phone is not up-to-date. Please notify user to update MGWatch app in order to use all the features properly.
MGWATCH_SERVICE_DISCONNECTED MG Watch Service is disconnected. This is not an expected behaviour. Please contact MAD Gaze CS Team.
UNABLE_TO_START_NOT_CONNECTED startGestureDetection() was failed because MAD Gaze Watch is not connected.
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).

Disclaimer

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

Copyright © 2021 MAD Gaze. All rights reserved.