语言

Menu
Sites
Language
Watchface (Get next alarm)

Slightly related to: https://developer.tizen.org/forums/native-application-development/watch-face-countdown-timer

I'm currently working on creating a watchface (gear s3) and would like to display the next upcoming alarm set on the device (Alarm Widget) above the current time. I tried the approach described here, but the application fails to enter the foreach:

static bool
on_foreach_registered_alarm(int alarm_id, void *user_data)
{
 dlog_print(DLOG_INFO, TAG, "Checking: %d", alarm_id); // Does not get logged
 [...]
 return true;
}

static void
create_base_gui(appdata_s *ad, int width, int height)
{
 [...]
 dlog_print(DLOG_INFO, TAG, "Checking Alarms!"); // Gets logged
 ret = alarm_foreach_registered_alarm(on_foreach_registered_alarm, user_data);
 [...]
}

static bool
app_create(int width, int height, void *data)
{
 appdata_s *ad = data;
 create_base_gui(ad, width, height);
 return true;
}

I'm fairly new to Tizen OS development, but I do suspect some sort of isolation going on between applications.

Can someone give me a hint on how to get the alarms set by the Alarm Widget?

 

编辑者为: Walentin Lamonos 02 1月, 2018

响应

5 回复
GEUNSOO KIM

Usually it means that there is no registered alarm.

Did you schedule any alarm when you run the code?

And I cannot sure that tizen allows getting other app's alarm or not, so try schedule an alarm on your app also to check which one is calling.

Thanks.

 

Walentin Lamonos

Yes, I had an alarm scheduled (on the emulator and on the device).

I'll try scheduling an alarm via the program first and then iterating that one.

Yasin Ali

Hi,

Log AlarmID other than the function create_base_gui. Choose a function that works after create_base_gui.

See life cycle to get better understanding on how UI App loaded.

https://developer.tizen.org/development/guides/native-application/application-management/applications#life-cycle

Also make sure you have alarm set such that it could be logged to test.

For more resources on code hint:

http://developer.samsung.com/gear/develop/creating-your-first-app/native-watch-face

https://developer.tizen.org/ko/development/training/native-application/getting-started/creating-your-first-tizen-wearable-native-widget-application?langredirect=1

Hope it will help you.

 

Walentin Lamonos

Tried that, I put the loop into update_watch​ (for testing obviously). Continously returns 0, no matter how long it runs. 

And stated above, I do have an alarm scheduled in both the emulator and the device.

Yasin Ali

In your implementation

ret = alarm_foreach_registered_alarm(on_foreach_registered_alarm, user_data);

what is user_data?

Try to adapt implementation in this way:

ret = alarm_foreach_registered_alarm(on_foreach_registered_alarm, NULL);
if (ret != ALARM_ERROR_NONE)
    dlog_print(DLOG_ERROR, TAG, "Listing Error: %d ", ret);
 
According to API Guide for alarm , link
https://developer.tizen.org/ko/development/api-references/native-application?redirect=/dev-guide/4.0.0/org.tizen.native.wearable.apireference/group__CAPI__ALARM__MODULE.html#ga4c7c25368e48fff0f41317e7d851e354


int alarm_foreach_registered_alarm  ( alarm_registered_alarm_cb  callback, 
  void *  user_data 
 )

 this function will return 0 on success, otherwise a negative error value.
  
Details:

int alarm_foreach_registered_alarm  ( alarm_registered_alarm_cb  callback, 
  void *  user_data 
 ) 


Retrieves the IDs of all registered alarms by invoking a callback once for each scheduled alarm.
Since :2.3.1   

Privilege Level:public

Privilege:http://tizen.org/privilege/alarm.get Parameters:
[in] callback The callback function to invoke 
[in] user_data The user data to be passed to the callback function

Returns:0 on success, otherwise a negative error value

Return values:
ALARM_ERROR_NONE                                              = Successful 
ALARM_ERROR_INVALID_PARAMETER                  = Invalid parameter 
ALARM_ERROR_CONNECTION_FAIL                    = Failed to connect to an alarm server 
ALARM_ERROR_PERMISSION_DENIED                  = Permission denied

Postcondition:
This function invokes alarm_registered_alarm_cb() repeatedly for each registered alarm.

Hope it will help.