tags:

views:

60

answers:

2

I'm just getting up to speed in Android, and today in a project meeting someone said that Android has no native calendar app so users just use whatever calendar app they like.

Is this true, and if so how do I programmatically add an event to the user's calendar? Is there a common API they all share?

FWIW we're probably targeting 2.x

A: 

Google calendar is the "native" calendar app. As far as I know, all phones come with a version of it installed, and the default SDK provides a version.

You might check out this tutorial for working with it.

Mayra
+1  A: 

how do I programmatically add an event to the user's calendar?

Which calendar?

Is there a common API they all share?

No, no more than there is a "common API they all share" for Windows calendar apps. There are some common data formats (e.g., iCalendar) and Internet protocols (e.g., CalDAV), but no common API. Some calendar apps don't even offer an API.

If there are specific calendar applications you wish to integrate with, contact their developers and determine if they offer an API. So, for example, the Calendar application from the Android open source project, that Mayra cites, offers no documented and supported APIs. Google has even explicitly told developers to not use the techniques outlined in the tutorial Mayra cites.

Another option is for you to add events to the Internet calendar in question. For example, the best way to add events to the Calendar application from the Android open source project is to add the event to the user's Google Calendar via the appropriate GData APIs.

CommonsWare
We don't want to target a specific calendar - we just want to be able to add events to whatever calendar the user is using, just as a convenience to the user. Our app provides an interface to a website that organizes professional meetings and conferences. So if someone signs up for one it would be nice to pop it into their calendar.
Peter Nelson
I think that using the unofficial api is currently the best way to do that, even if Google discourages that.
fhucho
@Peter Nelson: "We don't want to target a specific calendar - we just want to be able to add events to whatever calendar the user is using, just as a convenience to the user." -- you can't do that on Android any more than you can do that on Windows. On neither platform do you know "whatever calendar the user is using", and on neither platform is there a universal API for working with such a calendar application.
CommonsWare
I don't know why you keep comparing it to Windows - Everybody I know uses their phone to organize their schedules and appointments - I don't know anyone who does that on their PC - maybe it's a generational thing. But I get that Android can't do that. Thanks.
Peter Nelson
@Peter Nelson: I keep comparing it to Windows because people make the same assumptions. A lot of developers think they can "add events to whatever calendar the user is using" on Windows, because they think everyone uses Outlook, and hence there is only one "whatever calendar".
CommonsWare