Via Cà Matta 2 - Peschiera Borromeo (MI)
+39 02 00704272
info@synaptica.info

Delphi XE5 – Share JCalendar Event on Android

Digital solution partner

Delphi XE5 – Share JCalendar Event on Android

 {$IFDEF ANDROID},Androidapi.JNI.GraphicsContentViewText,
  FMX.Helpers.Android, IdURI,
  Androidapi.JNI.JavaTypes, Androidapi.Jni.Net,
  Androidapi.JNIBridge {$ENDIF};

The Java TimeInMills is similar to UnixTime but is in Millisenconds, so to convert it :

JavaTimeinMills := DateUtils.DateTimeToUnix(now) * 1000;
procedure TfrmTimeDetail.btnShareClick(Sender: TObject);
{$IFDEF ANDROID}
var
  Intent: JIntent;
  CalendarIni: JCalendar;
  Uri : string;
begin
  Uri      := 'content://com.android.calendar/events';
Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_EDIT,
TJnet_Uri.JavaClass.parse(StringToJString(TIdURI.URLEncode(uri))));

//Intent.setType(StringToJString('vnd.android.cursor.item/event'));
intent.putExtra(StringToJString('beginTime'), DateTimeToUnix( (clDay.Date + teTimeDal.Time)) * 1000 );
intent.putExtra(StringToJString('allDay'), false);
intent.putExtra(StringToJString('rrule'), StringToJString('FREQ=YEARLY'));
intent.putExtra(StringToJString('endTime'), DateTimeToUnix( (clDay.Date + teTimeAl.Time)) * 1000 );
intent.putExtra(StringToJString('title'), StringToJString(edCommessa.Text));
intent.putExtra(StringToJString('description'), StringToJString(Memo1.Text));
SharedActivity.startActivity(Intent);
end;

Leave a Reply