语言

Menu
Sites
Language
Wearable: any experience in alarms and task scheduling?

Hi all. I need to call a function inside ny app after a fixed delay. I thought that Tizen whould have something like a simple "timer" but no way!

Tizen SDK (I studied the wearable one) has the "alarm" something like an OS primitive that manage all the sheduled tasks (probably more like the Unix/Linux "at").

But you can't call an internal function, only "an operation recognized by the OS" like "open this link" or "open this image in editing mode". Then, is the OS that link the request to one of the installed providers (apps that can execute the request).

So I entered the wonderful world of ApplicationControl and ApplicationService, but I absolutely can't understand how they work! I found only a couple of example, none of them about the wearable SDK. The best is here (developer.tizen.org/documentation/articles/task-scheduling) but focuses only on ApplicationService that seems to be un-ported in the wearable versione of the SDK.

Nothing about using ApplicationControl. Nothing about what I supposed it was a really simple task: call a function with a delay of 5 minutes ...

Could someone please help me? Thank you.

查看选择的答案

响应

9 回复
Mark as answer

I don't understand your question but "Call a function with a 5 minutes delay?" should be simple in javascript!

// call appTimer every 1 seconds = 1000 milliseconds

var timer = setInterval(function() {
    appTimer()
}, 1000);

function appTimer() {
}

 

Stefano Accorsi

Well Nour you must know that I came from C# and Java development and know only a few thing about Javascript: you showed me my lack of knowledge about this programming alanguage. Thank you so much!

No problem, many devs here have issues with with html5/javascript and starts looking in the tizen docs and finds nothing

Look at setInterval and setTimeout functions

 

Stefano Accorsi

I used setInterval and is ok for what I needed now.

But how to schedule the execution of a function in Tizen wearable?

I mean, suppose something like an appointment alert in a calendar app. I couldn't use setInterval since:

1) is sensless to set those reminders based on the seconds between now and the appointment time
2) the alerts should came out even if the app is closed

So, for what I read, one should use the ApplicationControl paradigm (or the ApplicationService? but do it exist in the wearable SDK?)

I searched a lot in google but, as I wrote in the first message, I can't find anything useful. I find a nice scheduling example in Tizen (not wearable) that uses ApplicationService but as I wrote it seems it couldn't work in wearable (developer.tizen.org/documentation/articles/task-scheduling?langswitch=en) and a guide about ApplicationControl (developer.tizen.org/dev-guide/2.2.1/org.tizen.web.appprogramming/html/guide/app_guide/exporting_appcontrol.htm) but I didn't understand a word! Do you know another example? Or do you know if the alarm SDK is the same in Tizen and in the wearable version? If so I should buy and read the interesting book Professional Tizen application development.

Thank you.

This code launch the app everyday on 12:50

function autoLaunch() {
    var current = new Date();
    
       var alarmDate = new Date(current.getFullYear(), current.getMonth(), current
                .getDate(), 12, 50, 0, 0);

        alarm = new tizen.AlarmAbsolute(alarmDate,tizen.alarm.PERIOD_DAY);

            var app = tizen.application.getCurrentApplication();

        tizen.alarm.add(alarm, app.appInfo.id);       
}


 

After the app launches, you can check if it is the alarm time (for example, store the time in localStorage) and then do the job

 

Stefano Accorsi

Thank you so much for your reply!

I tried but I got an error while creating the alarm "Unknown error: Alarm scheduling failed" and nothing more ...

The code is so simple ... I really don't understand. TY

check the privilege and make sure the time in future..

it is daily alarm, it can be in the past. Make sure you have added "alarm" privilege to config.xml