Skip to Content
Android OptionsActivity Collection

Activity collection

Set Builder.userId to your stable player ID to enable tap-to-collect for collectible content authored in Graffity Console. The ID also scopes user-specific content requests.

import android.content.Context import tech.graffity.android.arcloud.publicapi.* class CollectionSession( context: Context, accessToken: String, playerId: String ) : GraffityARCloudListener { val sdk = GraffityARCloudSDK( context, GraffityARCloudConfiguration.Builder(accessToken) .mode(GraffityARMode.ARContent) .userId(playerId) .build() ).also { it.listener = this } override fun onContentCollected( sdk: GraffityARCloudSDK, contentId: String, activity: GraffityARActivity ) { println("Collected: $contentId") println("Progress: ${activity.collectedContentIds.size}/${activity.maxCollectionSize}") if (activity.isFinished) { // Present your app's completion UI. println("Finished activity: ${activity.id}") } } suspend fun endSession() { sdk.listener = null sdk.shutdown() } }

Retain the owner and host its SDK view or fragment as in the quick start. Without userId, player collection cannot be submitted. Ordinary content still needs a collection effect to become collectible.

Collection result

GraffityARActivity is a data class with read-only properties:

PropertyTypeMeaning
idStringActivity identifier.
projectIdStringProject or campaign.
playerIdStringParticipating player.
isFinishedBooleanCompletion status.
collectedContentIdsList<String>Collected content database IDs.
maxCollectionSizeIntRequired collection size.
bannerImageUrlUri?Optional banner.
collectionEmptyImageUrlUri?Optional empty-slot image.
collectionActiveImageUrlUri?Optional filled-slot image.
lastModifiedInstant?Last server modification.

Use callbacks to update your app’s progress and completion UI. Collection works with default GraffityARTelemetry.Disabled.