Hallo,
ich möchte einen Termin in einen Kalendar eintragen. Dazu habe ich folgenden Code:
Code
public void addEvent(String title, long calendarid, int color, Calendar timefrom, Calendar timeto, boolean wholeday, String timezone, String rrule, ArrayList<Reminder> reminders, String location, String description) {
ContentResolver cr = this.c.getContentResolver();
ContentValues values = new ContentValues();
System.out.println("Adding " + title + ", CalendarID: " + calendarid + ", " + color + ", " + timefrom.getTimeInMillis() + ", " + timeto.getTimeInMillis() + ", "
+ (timeto.getTimeInMillis() - timefrom.getTimeInMillis()) + ", " + timezone + ", " + rrule + ", " + location + ", " + description);
values.put(CalendarContract.Events.TITLE, title);
values.put(CalendarContract.Events.CALENDAR_ID, calendarid);
values.put(CalendarContract.Events.EVENT_COLOR_KEY, 0xff000000 - color);
values.put(CalendarContract.Events.DTSTART, timefrom.getTimeInMillis());
values.put(CalendarContract.Events.DTEND, timeto.getTimeInMillis());
if(wholeday == true) {
values.put(CalendarContract.Events.ALL_DAY, 1);
}
else {
values.put(CalendarContract.Events.ALL_DAY, 0);
}
values.put(CalendarContract.Events.EVENT_TIMEZONE, timezone);
System.out.println("MEINERRULE: " + rrule);
values.put(CalendarContract.Events.RRULE, rrule);
values.put(CalendarContract.Events.EVENT_LOCATION, location);
values.put(CalendarContract.Events.DESCRIPTION, description);
if(reminders.size() > 0) {
values.put(CalendarContract.Events.HAS_ALARM, 1);
}
else {
values.put(CalendarContract.Events.HAS_ALARM, 0);
}
Uri uri = cr.insert(CalendarContract.Events.CONTENT_URI, values);
Alles anzeigen
Der Termin wird eingetragen, aber:
Die eingetragene Farbe stimmt nicht. Es wird immer die Farbe vom Default-Kalender (nämlich -6306073) eingetragen. Was mache ich falsch?