Custom widget with next alarm & calendar event

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
nicsergio
Posts: 15
Joined: 19 Aug 2014 07:58

Custom widget with next alarm & calendar event

Post by nicsergio » 26 Oct 2014 13:10

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

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Custom widget with next alarm & calendar event

Post by Martin » 27 Oct 2014 17:47

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

User avatar
nicsergio
Posts: 15
Joined: 19 Aug 2014 07:58

Re: Custom widget with next alarm & calendar event

Post by nicsergio » 29 Oct 2014 14:53

great!
I tried and both actions are working properly, with Automagic you can really do all!! :D

User avatar
AMChris
Posts: 42
Joined: 22 Oct 2014 08:39

Re: Custom widget with next alarm & calendar event

Post by AMChris » 25 Nov 2014 08:05

@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...

User avatar
AMChris
Posts: 42
Joined: 22 Oct 2014 08:39

Re: Custom widget with next alarm & calendar event

Post by AMChris » 25 Nov 2014 08:06

the trigger is a calender event
(if an event starts - what is the next event?)
Attachments
2014-11-25 08_55_10-Screenshot_2014-11-25-08-44-13.png - IrfanView (Zoom_ 380 x 675).png
2014-11-25 08_55_10-Screenshot_2014-11-25-08-44-13.png - IrfanView (Zoom_ 380 x 675).png (100.76 KiB) Viewed 18880 times
Last edited by AMChris on 25 Nov 2014 08:07, edited 1 time in total.

User avatar
AMChris
Posts: 42
Joined: 22 Oct 2014 08:39

Re: Custom widget with next alarm & calendar event

Post by AMChris » 25 Nov 2014 08:07

now we query the calender
Attachments
2014-11-25 08_54_22-Screenshot_2014-11-25-08-44-38.png - IrfanView (Zoom_ 418 x 742).png
2014-11-25 08_54_22-Screenshot_2014-11-25-08-44-38.png - IrfanView (Zoom_ 418 x 742).png (121.95 KiB) Viewed 18880 times

User avatar
AMChris
Posts: 42
Joined: 22 Oct 2014 08:39

Re: Custom widget with next alarm & calendar event

Post by AMChris » 25 Nov 2014 08:08

second part of the 'query'
(I aks for a whole table because I want to get more information than only the title)
Attachments
2014-11-25 08_54_50-Screenshot_2014-11-25-08-44-44.png - IrfanView (Zoom_ 380 x 675).png
2014-11-25 08_54_50-Screenshot_2014-11-25-08-44-44.png - IrfanView (Zoom_ 380 x 675).png (91.96 KiB) Viewed 18880 times

User avatar
AMChris
Posts: 42
Joined: 22 Oct 2014 08:39

Re: Custom widget with next alarm & calendar event

Post by AMChris » 25 Nov 2014 08:10

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);
}
Attachments
2014-11-25 09_19_39-CC-Posteingang - Sven.Hofians@inhouse.wko.at - Microsoft Outlook.png
2014-11-25 09_19_39-CC-Posteingang - Sven.Hofians@inhouse.wko.at - Microsoft Outlook.png (22.2 KiB) Viewed 18879 times

angelatwork
Posts: 186
Joined: 12 Feb 2014 01:45

Re: Custom widget with next alarm & calendar event

Post by angelatwork » 15 Dec 2014 12:01

Hi AMchris, why don't you share your flow with us?

Would appreciate it

Best regards AngelAtwOrk
Best regards,
AngelAtwOrk

Post Reply