To present the Unsplash photo picker UI to the user, create an Intent using the UnsplashPickerActivity.getStartingIntent method. You can specify whether the user is allowed to select multiple photos by passing true or false to the isMultipleSelection parameter.
When the user finishes selecting photos, the activity returns an Intent containing the selected photos in the EXTRA_PHOTOS extra.
// Launching the picker for single selection
val intent = UnsplashPickerActivity.getStartingIntent(context, false)
startActivityForResult(intent, REQUEST_CODE)
// Launching the picker for multiple selection
val intent = UnsplashPickerActivity.getStartingIntent(context, true)
startActivityForResult(intent, REQUEST_CODE)
// Handling the result in onActivityResult
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK) {
val selectedPhotos = data?.getParcelableArrayListExtra<UnsplashPhoto>(UnsplashPickerActivity.EXTRA_PHOTOS)
// Use the selected photos
}
}