Firemonkey Android Access Calendar and Events

2020-07-24 03:42发布

How do I access the Calendar and Events on Android using Delphi XE5.

2条回答
Explosion°爆炸
2楼-- · 2020-07-24 04:40

in XE5 they started with PlatformServices and put Pickers Service into it: http://docwiki.embarcadero.com/Libraries/XE5/en/FMX.Pickers.IFMXPickerService

probably this piece of code will be usable for you:

  var
      PickerService: IFMXPickerService;
    begin
       if PlatformServices.Current.SupportsPlatformService(
           IFMXPickerService, Interface(PickerService))
    then
        FDateTimePicker := PickerService.CreateDateTimePicker;
        ...   // or
        FListPicker := PickerService.CreateListPicker;
查看更多
ゆ 、 Hurt°
3楼-- · 2020-07-24 04:42

To access the calendar you can use the Calendar class which is represented by the JCalendar class in Delphi.

You can find a set of samples here

And this is a Delphi sample

uses
  Androidapi.JNI.GraphicsContentViewText,
  FMX.Helpers.Android,
  Androidapi.JNI.JavaTypes;


procedure TForm1.Button1Click(Sender: TObject);
var
  Intent: JIntent;
  Calendar: JCalendar;
begin
  Calendar := TJCalendar.JavaClass.getInstance;
  Intent := TJIntent.Create;
  Intent.setType(StringToJString('vnd.android.cursor.item/event'));
  intent.putExtra(StringToJString('beginTime'), Calendar.getTimeInMillis());
  intent.putExtra(StringToJString('allDay'), true);
  intent.putExtra(StringToJString('rrule'), StringToJString('FREQ=YEARLY'));
  intent.putExtra(StringToJString('endTime'), Calendar.getTimeInMillis()+3600*1000);
  intent.putExtra(StringToJString('title'), StringToJString('Hello from Delphi'));
  SharedActivity.startActivity(Intent);
end;
查看更多
登录 后发表回答