Skip to Content
Android OptionsContent Taps and URLs

Content taps and URL handling

Use GraffityARCloudListener to receive taps and intercept links from content or the map. Assign it before attaching the view. The SDK holds the listener weakly, so retain it in your host.

import android.content.Context import android.net.Uri import tech.graffity.android.arcloud.publicapi.* class ContentEvents : GraffityARCloudListener { override fun onContentTapped(sdk: GraffityARCloudSDK, contentId: String) { println("Tapped content: $contentId") } override fun onRequestOpenUrl( sdk: GraffityARCloudSDK, url: Uri, source: GraffityAROpenUrlSource ): Boolean { when (source) { is GraffityAROpenUrlSource.ARContent -> println("Link from content: ${source.contentId}") GraffityAROpenUrlSource.Map -> println("Link from the map") } return false // Let the SDK open its Custom Tab. } } class ContentSession(context: Context, accessToken: String) { val events = ContentEvents() val sdk = GraffityARCloudSDK( context, GraffityARCloudConfiguration.Builder(accessToken) .mode(GraffityARMode.ARContent) .build() ).also { it.listener = events } suspend fun endSession() { sdk.listener = null sdk.shutdown() } }

Retain ContentSession while hosting its SDK surface. Listener callbacks run on the main dispatcher; move expensive work to your own background scope.

Content behavior

Author content and its tap effects in Graffity Console. onContentTapped returns the content’s database ID, matching the IDs in collection results. It is a notification; there is no return value to suppress built-in content effects.

Handle a URL in your app

Return true from onRequestOpenUrl when your app takes responsibility for routing or opening the URI. Return false, or omit the callback, for the SDK’s default Custom Tab behavior.

Use source to distinguish ARContent(contentId) from Map. Intercept your app’s custom URI schemes here if they need native routing.

All listener methods have defaults. Implement only the callbacks you need. Collection reports a separate onContentCollected event.