Page 1 of 1

Custom widget with next alarm & calendar event

Posted: 26 Oct 2014 13:10
by nicsergio
Hi Martin

I'm creating a custom widget with clock and other additional information, is there a way to get the next alarm time and next calendar event info?
Thanks

Re: Custom widget with next alarm & calendar event

Posted: 27 Oct 2014 17:47
by Martin
Hi,

Next alarm can be queried using action Init Variable System Setting and next_alarm_formatted.
Next calendar info can be queried with action Query Content Provider, however this action is quite difficult to use. There's an example to query the current calendar events. You could increase the time range in the content uri ...instances/when/{triggertime}/{addDays(triggertime,3)} to read the events of the next three days and limit the selection to begin>{triggertime} to ignore events that already started and sort order to end (untested).

Regards,
Martin

Re: Custom widget with next alarm & calendar event

Posted: 29 Oct 2014 14:53
by nicsergio
great!
I tried and both actions are working properly, with Automagic you can really do all!! :D

Re: Custom widget with next alarm & calendar event

Posted: 25 Nov 2014 08:05
by AMChris
@nicsergio: thanks for asking this question
@Martin: thanks for answering it ;)

I want to add my solution for 'get next event' which maybe of use for others...

Re: Custom widget with next alarm & calendar event

Posted: 25 Nov 2014 08:06
by AMChris
the trigger is a calender event
(if an event starts - what is the next event?)

Re: Custom widget with next alarm & calendar event

Posted: 25 Nov 2014 08:07
by AMChris
now we query the calender

Re: Custom widget with next alarm & calendar event

Posted: 25 Nov 2014 08:08
by AMChris
second part of the 'query'
(I aks for a whole table because I want to get more information than only the title)

Re: Custom widget with next alarm & calendar event

Posted: 25 Nov 2014 08:10
by AMChris
now I use a script to extract the content

Code: Select all

/*
SELECT title,begin,calendar_displayName,end,eventLocation 
FROM content://com.android.calendar/instances/when/{triggertime}/{addDays(triggertime,3)} 
WHERE begin>{triggertime} ORDER BY begin
*/
global_next_event_title=getElement(getElement(event_table, 0),0);
global_next_event_begin=getElement(getElement(event_table, 0),1);
global_next_event_calendarName=getElement(getElement(event_table, 0),2);
global_next_event_end=getElement(getElement(event_table, 0),3);
global_next_event_location=getElement(getElement(event_table, 0),4);
global_next_event_day="";
if ("{global_next_event_begin,dateformat,yyyyMMdd}"!="{getDate(),dateformat,yyyyMMdd}") {
   global_next_event_day=left("{global_next_event_begin,dateformat,E}",2);
}

Re: Custom widget with next alarm & calendar event

Posted: 15 Dec 2014 12:01
by angelatwork
Hi AMchris, why don't you share your flow with us?

Would appreciate it

Best regards AngelAtwOrk