Tizen Wearable Web Widget visibilityChange and Debug

旧城冷巷雨未停 提交于 2021-01-07 02:50:49

问题


I am having some problems with Tizen wearable Web Widgets.

I just created a sample project with HTML + JS and tried to update page on events described in life-cycle -> On load / visibility change

the sample code can be found at: https://github.com/Ryccoo/widget-test/blob/master/widget/StockQuote/js/main.js

When I add widget I can see the text "something" -> meaning that onload function was successfully called.

However swiping to another widget and back does not trigger the visibilityChange event as described.

How do I correctly upload the contents when user scrolls to this widget ?

Another question is just how to debug the web widgets? You cant run debug to interactively debug the program with widgets (only for web apps) and when I want to print something to console I only see

The web console logging API (console.log, console.info, console.warn, console.error) has been disabled. To activate it, you should launch project with Debug mode.

How do I launch the widget in Debug mode ?

Thank you


回答1:


Web Widget Debug feature is not Supported yet on Tizen Studio.

But I've test the code for Visibility Change event, and It worked fine on my Samsung Gear S3. Visibility Change callback is being called every time I change between widgets. You may give this code sample a try:

Project folder > Widget folder> index.html

<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" type="text/css" href="css/style.css">
</head>

<body>
    <div class="main-container Panel">
        <div id="Visibility"> Visibilty: Init </div>
    </div>
  <script src="js/main.js"></script>
</body>

</html>

Project folder > Widget folder> js > main.js

window.onload = function() {

};

document.addEventListener('visibilitychange', visibilitychange);

function visibilitychange() {
    if (document.visibilityState === 'hidden') {
        document.getElementById("Visibility").textContent = "Hidden";
    } else {
        document.getElementById("Visibility").textContent = "Visible";
    }
}


来源:https://stackoverflow.com/questions/51411910/tizen-wearable-web-widget-visibilitychange-and-debug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!