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

test[jx8Intents] Open document

SwikiCodeRobot @> 583

"Open a specific type of file"
| intent context |
context := MainActivity current.
intent := Intent action: Intent actionOpenDocument.
intent type: 'image/*'.
intent addCategory: Intent categoryOpenable.
(intent resolveActivity: context packageManager) isNil ifTrue: [
	self error: 'Intent canīt be resolved'
	when: #onActivityResult:with:with:with:
	do: [:reqCode :resCode :intent :activity | 
		self print: 'intent=', intent.
		self print: 'reqCode=', reqCode asString, ' - ', 'resCode=', resCode asString.
		(reqCode = 1 and: [ resCode = -1 ]) ifTrue: [
        	self print: 'fullPhotoUri=', intent data.
        	" Do work with full size photo saved at fullPhotoUri "
		self print: 'OK!'.
context startActivityForResult: intent requestCode: 1"REQUEST_IMAGE_OPEN".