How to use the ambient events in low-powered wearable device?

■ Summary

- The watch can show a limited UI to reduce power consumption in the ambient mode.
- The watch receives a tick event every minute in the ambient mode.
/*********************************************************
* [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); 
    }    
}); 

Responses

0 Replies