First Release
Updates
Date | Watch SDK (Gradle) | Demo Project (.zip) | |
---|---|---|---|
02/03/2021 | com.madgaze.smartwatch:development-kit-watch:1.1.0 | Download |
Android SDK for Mobile provides the following functions:
Gestures performed by single hand finger movements, such as snapping.
Gestures performed by finger tapping on hand, fingers and forearm.
Arm Movements
Install MGWatch from Android Store (Currently, SDK is not available on iOS devices.)
Complete Personalised Setup Training from MGWatch app.
Open existing Android Project or Create a new Android Project.
Add the dependency settings in gradle file app/build.gradle.
implementation 'com.madgaze.smartwatch:development-kit-watch:1.1.0'
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.
Create a Blank Activity
Inherits current Activity class from MobileActivity
public class MainActivity extends MobileActivity {
...
}
Create the implementation for the following inherited methods.
Method | Description |
---|---|
onMGWatchServiceReady() |
Callback invokes when MG Watch Service (which is Preinstalled with MGWatch) is connected.
|
onWatchConnected() | Callback invokes when MAD Gaze Watch is connected. |
onWatchDisconnected() |
Callback invokes when MAD Gaze Watch is disconnected.
|
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.
|
onWatchGestureReceived(WatchGesture) | Callback invokes when a Watch Gesture is recognized. |
onWatchGestureError(WatchException) | Callback invokes when Watch Recognition or Initialization was unsuccessful. |
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;
}
Developers can check if the required (declared) gestures are trained before with the following code snippets.
boolean isGesturesReady = MGWatch.isGesturesTrained(ctx);
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);
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
}
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 the gesture recognition.
MGWatch.stopGestureDetection(this);
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.
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);
}
}
}
@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. |
First Release
Updates
This library is licensed under the MAD Gaze - Terms of Use.