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

test[jx8Intents] Alarm


SwikiCodeRobot @> 576

" Creating an Alarm "
| intent context scope |
Intent ensurePermission: 'com.android.alarm.permission.SET_ALARM'.
context := MainActivity current.
scope := 'android.intent.extra.alarm.'.
intent := Intent action: 'android.intent.action.SET_ALARM'.
intent
	putExtra: scope ,#MESSAGE value: 'Sample test alarm';
	putExtra: scope ,#HOUR value: DateTime now hours;
	putExtra: scope ,#MINUTES value: DateTime now minutes + 1;
	yourself.
(intent resolveActivity: context packageManager) isNil ifTrue: [
	self error: 'Intent canīt be resolved'
].
context startActivity: intent.
^#Ok