[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[jx8Intents] Calendar Event


SwikiCodeRobot @> 581

"Add a calendar event"
| beginTime endTime context intent |
(Smalltalk includesKey: #CalendarContract_Events) ifFalse: [
JavaObject buildSubclasses: #(
	CalendarContract
) in: 'android.provider'.
JavaObject buildNestedSubclasses: #(#(CalendarContract #(#Events))).
CalendarContract_Events buildConstants: #(CONTENT_URI) 
].
context := MainActivity current. 
beginTime := (Calendar instance set: 2018 month: 0 date: 27 hourOfDay: 8 minute: 30) ; yourself.
endTime := (Calendar instance set: 2018 month: 0 date: 27 hourOfDay: 9 minute: 30) ; yourself.
intent := Intent action: Intent actionInsert.
intent
	data: CalendarContract_Events contentUri;
	putExtra: #beginTime value: beginTime timeInMillis;
	putExtra: #endTime value: endTime timeInMillis;
	putExtra: #title value: 'tennis match';
	putExtra: #eventLocation value: 'hard court';
	yourself.
(intent resolveActivity: context packageManager) isNil ifTrue: [
	self error: 'Intent canīt be resolved'
].
context startActivity: intent.
^#Ok