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

test[jx8Intents] Timer


SwikiCodeRobot @> 577

" Creating an Timer "
| 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_TIMER'.
intent
	putExtra: scope ,#MESSAGE value: 'Sample test timer';
	putExtra: scope ,#LENGTH value: 10"seconds";
	putExtra: scope ,#SKIP_UI value: true;
	yourself.
(intent resolveActivity: context packageManager) isNil ifTrue: [
	self error: 'Intent canīt be resolved'
].
context startActivity: intent.
^#Ok