function TCalendarEventsManager.AddNewReminder(ADate: TDate; ATitle: string): integer;
var
wEvent : JContentValues;
wUri : Jnet_Uri;
begin
try
wEvent := TJContentValues.JavaClass.init;
wEvent.put(StringToJString('calendar_id'), TJInteger.JavaClass.init(fCalendarID));
wEvent.put(StringToJString('title'), StringToJString(ATitle));
// wEvent.put(StringToJString('description'), StringToJString('Description here if needed'));
wEvent.put(StringToJString('dtstart'), TJLong.JavaClass.init(MilliSecondsBetween(ADate , EncodeDate(1970,1,1))));
wEvent.put(StringToJString('dtend'), TJLong.JavaClass.init(MilliSecondsBetween(ADate , EncodeDate(1970,1,1))));
wEvent.put(StringToJString('eventTimezone'), StringToJString('Europe/London'));
wEvent.put(StringToJString('allDay'), TJBoolean.JavaClass.init(StringToJString('true')));
wEvent.put(StringToJString('hasAlarm'), TJBoolean.JavaClass.init(StringToJString('true')));
wEvent.put(StringToJString('accessLevel'), TJInteger.JavaClass.init(3));
// wEvent.put(StringToJString('guestsCanModify'), TJBoolean.JavaClass.init(StringToJString('true')));
wUri := fContentResolver.insert(StrToJURI('content://
com.android.calendar/events'),wEvent);
Result := StrToInt(JStringToString(wUri.getLastPathSegment()));
wEvent.clear;
wEvent.put(StringToJString('event_id'),TJInteger.JavaClass.init(Result));
wEvent.put(StringToJString('method'),TJInteger.JavaClass.init(1));
wEvent.put(StringToJString('minutes'),TJInteger.JavaClass.init(30));
wEvent.put(StringToJString('event_id'),TJInteger.JavaClass.init(Result));
fContentResolver.insert(TJCalendarContract_Reminders.JavaClass.CONTENT_URI, wEvent);
except
On E:
Exception do
Raise
Exception.create('[TCalendarEventsManager.AddNewReminder] : '+E.message);
end;
end;