Use the SDK
2
Set Up PlaytimeOptions and ShowCatalog
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
try {
val userId = "example_user_id"
val sdkHash = "example_sdk_hash"
val playtimeParams = PlaytimeParams.Builder()
.setUaNetwork("tiktok")
.setUaChannel("video")
.setUaSubPublisherCleartext("Example: Game 2")
.setUaSubPublisherEncrypted("8bb1e7911818be32449f6726ff7ecd102ba1862b")
.setPlacement("Main Screen")
.setPromotionTag("promotion-id")
.build()
val playtimeExtensions = PlaytimeExtensions.Builder()
.setSubId1("Target Group 1")
.setSubId2("Target Group 2")
.build()
val isoDateString = "2025-06-26T14:45:30.123Z"
val birthday: Date = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US)
.apply { timeZone = TimeZone.getTimeZone("UTC") }
.parse(isoDateString)!!
val gender = PlaytimeGender.MALE
val playtimeUserProfile = PlaytimeUserProfile(gender, birthday)
val options = PlaytimeOptions()
.setUserId(userId)
.setSDKHash(sdkHash)
.setParams(playtimeParams)
.setUserProfile(playtimeUserProfile)
.setExtensions(playtimeExtensions)
// Add catalog listener with event type always being catalog.
// To remove the listener, simply call Playtime.removeCatalogListener().
Playtime.setCatalogListener(object : PlaytimeCatalogListener() {
override fun onCatalogOpened(type: String) {
Log.d(TAG, "Catalog of type '$type' was opened")
}
override fun onCatalogClosed(type: String) {
Log.d(TAG, "Catalog of type '$type' was closed")
}
})
// Show catalog and pass in the playtimeOptions
Playtime.showCatalog(activity, options)
} catch (exception: PlaytimeException) {
// Handle playtime exceptions
} catch (exception: Exception) {
// Handle other exceptions
}
}
}Using setPlaytimeOptions
Playtime.setPlaytimeOptions(options, object : PlaytimeOptionsListener() {
override fun onSuccess() {
Log.d(TAG, "SDK was initialized successfully")
}
override fun onError(error: String) {
Log.d(TAG, "An error occured initalizing the SDK: $error")
}
})Using getStatus to showCatalog
val status = Playtime.getStatus()
Log.d("ADJOE", "Current SDK Status: ${status}")
if (status.isInitialized) {
try {
// Pass options directly to showCatalog
val options = activity.getPlaytimeOptions()
Playtime.showCatalog(activity, options)
} catch (e: Exception) {
Log.e("ADJOE", "Error launching catalog", e)
}
} else {
Log.w("ADJOE", "SDK is not initialized yet. Please try again in a moment.")
}Parameters
Parameter
Explanation
Additional Useful Methods
name
description
User Experience
Terms of Service
Access to Advertising Info
Last updated


