I am trying to build a calendar app for Android. I am struck in the middle. I have managed to retrieve the information such as time and task from the user.
I don't know how to add this into android events. Is there anything like setEvent
or something similar?
Nope, it is more complicated than just calling a method, if you want to transparently add it into the user's calendar.
You've got a couple of choices;
Calling the intent to add an event on the calendar
This will pop up the Calendar application and let the user add the event. You can pass some parameters to prepopulate fields:
Or the more complicated one:
Get a reference to the calendar with this method
(It is highly recommended not to use this method, because it could break on newer Android versions):
and add an event and a reminder this way:
You'll also need to add these permissions to your manifest for this method:
Update: ICS Issues
The above examples use the undocumented Calendar APIs, new public Calendar APIs have been released for ICS, so for this reason, to target new android versions you should use CalendarContract.
More infos about this can be found at this blog post.
You can use AlarmManager in coop with notification mechanism Something like this:
It starts alarm.
Android complete source code for adding events and reminders.
Add permission to your Manifest file.