语言

Menu
Sites
Language
Background operation on a watchface

Hi,

I am trying to add an hourly alarm to my watchface.

But when the screen is off,     animation frame stops.

So I can not check when minute is 0 and make the sound.

How can I set a timer to run in background ? Or another method to trigger a sound when minutes is 0.

In onload fuction I have this:

window.requestAnimationFrame = window.requestAnimationFrame       || 
            window.webkitRequestAnimationFrame || 
            window.mozRequestAnimationFrame    || 
            window.oRequestAnimationFrame      || 
            window.msRequestAnimationFrame     || 
            function(/* function */ callback){
                window.setTimeout(callback, 1000 / 60 );
            };

   window.onload = function() {

    window.addEventListener('tizenhwkey', function(e) {
        if(e.keyName == "back")
            tizen.application.getCurrentApplication().exit();
    });

   window.requestAnimationFrame(watch);

}

 

响应

9 回复
mekabe remain
 

ok. I found the solution. Instead of putting the window.requestAnimationFrame(watch) function to an interval, I created another function and put the animation frame request in it. 

mekabe remain

unfortunately, it works only if it is connected to power. When I disconnect power, the screen does not turn on.

Is there a method or priviledge for turning screen on when not connected to power ?

 

 

mekabe remain

I am trying to turn device screen on with tizen.power.turnScreenOn() on a hourly period. This command works when my Gear S is connected to power (charging) It turnsthe screen and the app continues whatever I put in the code.

However, when the device is not connected to power, the screen does not come on. How can I make it turn on screen when not in charge ?

Sample from that part of the code :

function startwatch () {
 var date1 = new tizen.TZDate();
 var seconds1 = date1.getSeconds();
 var minutes1 = date1.getMinutes();
 var hours1 = date1.getHours();
 var day1 = date1.getDate();
 var month1 = date1.getMonth();
 if (day1==23 & (month1+1)==11 & hours1>6 & minutes1==59 & seconds1==59){
    if (!tizen.power.isScreenOn()) {
        tizen.power.turnScreenOn();
        //tizen.power.request("SCREEN", "SCREEN_NORMAL");
    }
    setTimeout(alarmit,100);
 }

 if (tizen.power.isScreenOn()) {
    window.requestAnimationFrame(watch);
  }
}
AVSukhov

Hello,

You may try to use additional application setting in your configuration file:

background-support

mekabe remain

I have already added background-support to the config.xml

app can turn on screen when the device has external power.  but can not turn on screen without power attached.

any ideas ?

 

mekabe remain

please I need help...

 

AVSukhov

Hello,

Try to use Alarm API (add alarm with appcontrol)

"Tizen Wearable enables you to schedule an application to be run at a specific time using the Alarm API. When an alarm is triggered, the application is launched."

mekabe remain

thank you. but I don't know how to use that.

Actually, my app is a watchface. So what alarm should I set to keep it active ?

should I set an alarm to run every second ?

sounds weird. If anyone knows alarm API, I'd appreciate help...

 

daniel kim

Hi,

As far as I know, you can turn on the screen of Gear all the time by below api without charger.

            tizen.power.request("SCREEN", "SCREEN_NORMAL");

But it's commented in your code. so suggest to use this api.

I wish this will help you.