[How-To] Java - Insert, Update and Delete calendar entries

726 views
Skip to first unread message

Wietse van Buitenen

unread,
Mar 26, 2015, 3:56:13 PM3/26/15
to tas...@googlegroups.com
Hi,

I needed to delete a specific entry in a calendar on a regular basis so with the recent addition of Java in Tasker I has some options :)

I cleaned some stuff up but some things can probably be improved... for the time I had to spend on it it works fine and should allow you to understand and modify to your needs.

I attached a Project which you can import (it's exported in Tasker 4.7b5).

Since several parts are re-used I split them up in separate Tasks.

It consists of Tasks that will do the actual work:
Calendar - Get calendar_id
Calendar - Get event_id
Calendar - Insert
Calendar - Update
Calendar - Delete
These Tasks have some labels in them that describe the required Parameters.

Sample Tasks that demonstrate the use:
Calendar - Do Insert
Calendar - Do Update
Calendar - Do Delete

and 2 other Tasks that might be useful
Calendar - List Calendars
Calendar - List Events

Have fun :)
Calendar.prj.xml

Jakub

unread,
Mar 26, 2015, 4:26:39 PM3/26/15
to tas...@googlegroups.com
Is there a chance to get reccurence events?
or do you now how to get reccurence events from RRULE?

Wietse van Buitenen

unread,
Mar 26, 2015, 4:33:42 PM3/26/15
to tas...@googlegroups.com
I personally have no use for this in recurring events so didn't look into it.
I only noticed today while doing some final testing that recurring and all day events (possibly because the ones in my test were also recurring) weren't listed.

I'll look into it when I have some time..

Wietse van Buitenen

unread,
Mar 26, 2015, 5:48:09 PM3/26/15
to tas...@googlegroups.com
it seems you can add "rrule is not null" to the "where" String..
I quickly tested and it now lists my recurring events.. all of them so I need to change it a bit :)

perhaps tomorrow..


On Thursday, March 26, 2015 at 9:26:39 PM UTC+1, Jakub wrote:

Jakub

unread,
Mar 27, 2015, 2:57:34 AM3/27/15
to tas...@googlegroups.com
Thank you very very much

Jakub

unread,
Mar 27, 2015, 3:05:35 AM3/27/15
to tas...@googlegroups.com
Is there chance to get reccuring past events?

Richard Wallace

unread,
Mar 27, 2015, 8:14:10 AM3/27/15
to tas...@googlegroups.com
Just looking at this and it isn't retrieving any events in my calendar?

Wietse van Buitenen

unread,
Mar 27, 2015, 8:46:39 AM3/27/15
to tas...@googlegroups.com
You did replace the value MyCalendar in %cal_name with your calendar are?

Richard Wallace

unread,
Mar 27, 2015, 11:18:38 AM3/27/15
to tas...@googlegroups.com
I did the indeed.
Tried with different calendars.

Wietse van Buitenen

unread,
Mar 29, 2015, 8:54:09 AM3/29/15
to tas...@googlegroups.com
using the instances table instead of events I was able to load both recurring and all day events..
At this point there is still something with the timezones I need to look into...

Wietse van Buitenen

unread,
Mar 29, 2015, 9:00:59 AM3/29/15
to tas...@googlegroups.com
With the limited information you posted I can only tell you what works for me..

I just imported the Project on my Nexus 7 with Android 5.1, opened Calendar - List Events and changed %cal_name to a calendar present on the device and started the Task..
I returned the results fine..
The device on which I created it has Android 4.4.4 and works fine there too.

At this point it doesn't show recurring events or all day events so if the day you start the Task doesn't have a regular entry in the selected calendar it will not return any results.
You can select another day by editing the JaveScriptlet fromstep 3 in Calendar - List Events.

The third line is commented out (// in front of it).
You can uncomment it and change the number of days in the past or in the future to test.
Message has been deleted

krabbs

unread,
Apr 7, 2015, 8:46:45 AM4/7/15
to tas...@googlegroups.com
Hey can u please tell me how exactly u doing this or reupload your modified taskt.

i changed url to content://calendar/instances.with no luck. so read further in documentation and tried content://calendar/instances/when with new variables. but without succees. i would love to know what im doint wrong. and your tasks are the prefect start for my new idea. Thanks man

Wietse van Buitenen

unread,
Apr 7, 2015, 2:52:48 PM4/7/15
to tas...@googlegroups.com
Hi,

the Task itself needs some work and I don't really have the time for it now..
I got it up to a point where it shows the normal, recurring and all day items.. only the all day events seem to overlap 1 hour although I used UTC time as specified.. Will look into this when I have more time.

The URI is:
conten://com.android.calendar/instances/when/%dtstart/%dtend
where %dtstart is time to start looking in milliseconds converted to UTC..
%dtend is then the end of the range in milliseconds and UTC

hope this helps you out a bit..
Message has been deleted
Message has been deleted

krabbs

unread,
Apr 8, 2015, 6:37:57 AM4/8/15
to tas...@googlegroups.com
ok i found one mistake. but still same. =(
my problem is at this step:

cursor =cr.query(uri, projection, where, null, null) )

the error:
cause java.lang.reflect.InvocationTargetException

i modified projection so its include just _id and title. changed the uri you described. and removed the time information after your calendar id(where). and i think calendar id have to be set wih calendar._id = %cal_id. but i tried both ways

im uploading my task here, maybe you or somebody can look into this or just provide a modified task so i can see myself


thanks for your time and help in any case!
Calendar___List_EventsNew.tsk.xml

krabbs

unread,
Apr 8, 2015, 6:55:46 AM4/8/15
to tas...@googlegroups.com
ah **** sorry for spam all these who reading my posts =)

i found my problem. i totaly misunderstood the way the id is handled. its working now for me!!! thanks Wietse van Buitenen.
i will need some time too to get it working the full way but i can go from here

Wietse van Buitenen

unread,
Apr 8, 2015, 2:47:04 PM4/8/15
to tas...@googlegroups.com
glad you got it working :)

once I find the time to get recurring and all day working exactly as I would expect them to work I'll post the stuff here..

Bino Mathew

unread,
Jul 14, 2017, 5:25:08 AM7/14/17
to Tasker
Highly modular and perfectly written - You just a saved Google Play purchase for me!!!
Reply all
Reply to author
Forward
0 new messages