Gesture Recognition

You can set your application to recognize specific user gestures and react when the user performs them. The various recognizable gestures include, for example, when the user taps, shakes up, or picks up the device, or moves it along an axis.

This feature is supported in mobile and wearable applications only.

The main gesture recognition features of the Human Activity Monitor API include:

Checking the Gesture Support

Some gestures are not supported on all devices because the devices lack the necessary sensors.

To check whether a specific gesture type is supported on the current device, use the isGestureSupported() method of the HumanActivityMonitorManager interface (in mobile and wearable applications):

try {
    var isSupported = tizen.humanactivitymonitor.isGestureSupported('GESTURE_PICK_UP');
    console.log('GESTURE_PICK_UP is ' + (isSupported ? 'supported' : 'not supported'));
} catch (error) {
    console.log('Error ' + error.name + ': ' + error.message);
}

Receiving Notifications on Recognized Gestures

Learning how to register a listener for gesture recognition allows you to receive notifications about different gestures the user performs with a device:

  1. To register a listener, use the addGestureRecognitionListener() method of the HumanActivityMonitorManager interface (in mobile and wearable applications):

    var listenerId;
    
    function listener(data) {
        console.log('Received ' + data.event + ' event on ' + new Date(data.timestamp * 1000) + ' for '+ data.type + ' type');
    }
    
    function errorCallback(error) {
        console.log(error.name + ': ' + error.message);
    }
    
    try {
        listenerId = tizen.humanactivitymonitor.addGestureRecognitionListener('GESTURE_SHAKE', listener, errorCallback);
    } catch (error) {
        console.log('Error ' + error.name + ': ' + error.message);
    }
    
  2. To stop receiving the notifications, remove the listener using the removeGestureRecognitionListener() method of the HumanActivityMonitorManager interface with the listener ID:
    try {
        tizen.humanactivitymonitor.removeGestureRecognitionListener(listenerId);
    } catch (err) {
        console.log('Exception: ' + err.name);
    }