Languages

Menu
Sites
Language
Detecting watch is not on the wrist
Hi, it seems that when AOD mode and watch isnt on the wrist, it automatically shut down display, is there a callback for this state? Thanks

Responses

7 Replies
Yasin Ali

Hi~,

You may use code like below:

/*********************************************************
* [Step 1] Add the alarm privilege in config.xml
**********************************************************/
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" 
    ...
    <TIZEN:PRIVILEGE name="http://tizen.org/privilege/alarm" />    
    ...
</widget>


/*********************************************************
* [Step 2] Add eventListener for timetick in the ambient mode
**********************************************************/
window.addEventListener('timetick', function() {
    // TODO : Update the ambient view    
    updateAmbientWatch(); 
}); 


/*********************************************************
* [Step 3] Add eventListener for ambientmodechanged
**********************************************************/
window.addEventListener('ambientmodechanged', function(e) { 
    if (e.detail.ambientMode === true) {        
        // TODO : Rendering ambient mode case         
        updateAmbientWatch(); 
    } else {             
        // TODO : Rendering normal case    
        updateNormalWatch(); 
        
        watchInterval = setInterval(function() { 
            updateNormalWatch();
        }, 1000); 
    }    
});

Hope it will help you.
If you find my post is helpful for you, please mark it as the Best Answer to promote this post to others.

Tizen is me
Hi, thanks for answering Is the code is for detecting ambient mode? I'm looking for api that detect when watch is not on the wrist, maybe the system was using heart rate sensor for it? And I'm using native dev :)
Yasin Ali

You may use api for detecting motion sensor changed value or as you say heart rate sensor I think.

Tizen is me
Thanks, I wondered how the default app did it, since it can detect when the watch is not in contact but there's no light appears from back
Yasin Ali

Combination of different indirect measure you may have this does, I think.
Check https://developer.tizen.org/development/api-references/native-application?redirect=/dev-guide/latest/org.tizen.native.wearable.apireference/group__CAPI__CONTEXT__ACTIVITY__MODULE.html

enum activity_type_e

ACTIVITY_STATIONARY 
Stationary

And also check
https://developer.tizen.org/development/api-references/native-application?redirect=/dev-guide/latest/org.tizen.native.wearable.apireference/group__CAPI__CONTEXT__GESTURE__MODULE.html

enum gesture_event_e


GESTURE_EVENT_DETECTED 
Detected the gesture
 
GESTURE_SHAKE_DETECTED 
Shake gesture started
 
GESTURE_SHAKE_FINISHED 
Shake gesture stopped
 
GESTURE_SNAP_X_NEGATIVE 
Detected -X snap
 
GESTURE_SNAP_X_POSITIVE 
Detected +X snap
 
GESTURE_SNAP_Y_NEGATIVE 
Detected -Y snap
 
GESTURE_SNAP_Y_POSITIVE 
Detected +Y snap
 
GESTURE_SNAP_Z_NEGATIVE 
Detected -Z snap
 
GESTURE_SNAP_Z_POSITIVE 
Detected +Z snap
enum gesture_type_e
GESTURE_WRIST_UP 
The wearable device is moved and faced up


 

 

Tizen is me

Thanks man