public static int createEntry(String sEntryText, long nStartTime)
{
// VARs
Uri oUri;
// Add the timezone offset to the UTC time
nStartTime -= TimeZone.getDefault().getOffset(System.currentTimeMillis()) / 1000;
if(Globals.API_LEVEL >= 8)
{
oUri = EVENTS_CONTENT_URI_LEVEL_8;
}
else
{
oUri = EVENTS_CONTENT_URI;
}
ContentResolver oContentResolver = Globals.m_oRichMediaDriver.m_oActivity.getContentResolver();
// Create the calendar entry
ContentValues oValues = new ContentValues();
oValues.put(EVENTS_CALENDAR_ID, 1);
oValues.put(EVENTS_DT_START, nStartTime * 1000);
oValues.put(EVENTS_DESCRIPTION, sEntryText);
// Also define the title field
oValues.put(EVENTS_TITLE, sEntryText);
try
{
// Insert the new calendar entry in the calendar of the device.
oContentResolver.insert(oUri, oValues);
}
catch (Exception e)
{
}
}
Wednesday, October 10, 2012
Creating the enrty in the agenda for Android devices.
ContentResolver class is used to add the agenda. This will work for all the android SDK i.e. 1.5 and above. Offset for the timezone has been added so that it should work irrespective of UTC timezone.
Subscribe to:
Post Comments (Atom)

