private void setEvent(){ long startMilis = 0; int mCalId = 1; long endMilis = 0; Calendar beginTime = Calendar.getInstance(); beginTime.set(2013, 1, 29, 9, 10); startMilis = beginTime.getTimeInMillis(); Calendar endTime = Calendar.getInstance(); endTime.set(2013, 1, 30, 10,10); endMilis = endTime.getTimeInMillis(); ContentResolver cr = getContentResolver(); ContentValues values = new ContentValues(); values.put(Events.CALENDAR_ID, mCalId); values.put(Events.DTSTART, startMilis); values.put(Events.DTEND, endMilis); values.put(Events.TITLE,"Special Event"); values.put(Events.DESCRIPTION, "Group Activity"); values.put(Events.EVENT_TIMEZONE, "America/Los_Angeles"); Uri uri = cr.insert(Events.CONTENT_URI, values); Toast.makeText(this, "Event Added", Toast.LENGTH_LONG).show(); }
This is a snippet of my code where I want to add an event to the Android calendar. The code is working fine.
But when testing on the device, the specified event is not actually added or displayed on the calendar . The code is completely error free, and I have provided the necessary permissions.
Can someone please tell me exactly where I am doing wrong.
source share