Android quickstart
minSdk 24. Jetpack Compose and Views.
1. Install
Section titled “1. Install”dependencies { implementation("com.tryyoursize:tryyoursize-android:0.1.0") }2. Register your app
Section titled “2. Register your app”In Studio, add android-app://<your package> (lower case, for example android-app://com.brand.shop) to the allowed sites of your store for test mode.
3. Use it
Section titled “3. Use it”The window needs an androidx ComponentActivity (for example AppCompatActivity).
val tys = TryYourSize(context, "pk_test_…") // a secret key throws: keep sk_ on your server
// Compose, where your "Size guide" link was:Row(verticalAlignment = Alignment.CenterVertically) { Text("Size"); Spacer(Modifier.weight(1f)) SizeGuide(tys, "SKU-123", textStyle = MaterialTheme.typography.bodyMedium) { rec -> // On show and on every change. Preselect, but never over the shopper's own choice. if (rec.status == Recommendation.Status.READY && !touched) selected = rec.size }}
// Viewsval guide = SizeGuideView(context).apply { client = tys; product = "SKU-123"; variant = SizeGuideVariant.BUTTON }
// Without a buttonval rec = tys.recommendation("SKU-123") // suspend; or getRecommendation("SKU-123") { result -> }tys.present(activity, "SKU-123")tys.on { e -> if (e is TryYourSize.Event.Size) select(e.selection.size) }Call the SDK from the main thread.
Button states: “Size guide” → “Calculating your size…” → “Your size: M” (with the connected dot), or “Size guide · connected”. Labels follow locale (en, es, fr, de, it).
Recommendation: status (READY, COMPUTING, NO_SIZE, SIGNED_OUT, UNAVAILABLE), size in your labels, studioSize, wearableSizes. It never starts a simulation.
4. Appearance
Section titled “4. Appearance”By default (INHERIT) the button and the window take your theme’s text and background colours; the button takes the textStyle you pass.
val tys = TryYourSize(context, "pk_test_…", TryYourSize.Configuration( appearance = Appearance(colorPrimary = 0xFF3F51B5.toInt(), fontFamily = "Inter, Roboto", borderRadius = 12f, fonts = listOf("https://fonts.googleapis.com/css2?family=Inter:wght@400;600"))))tys.appearance = tys.appearance.copy(colorPrimary = Color.BLACK) // live: an open window restyles at once5. Events and errors
Section titled “5. Events and errors”- Events:
Ready,Open,Close,Size(SizeSelection),LoadError(TryYourSizeException). - Error codes (
TryYourSizeException.code):SECRET_KEY_IN_APP,INVALID_KEY,INVALID_APP_IDENTIFIER,INVALID_OPTION,WINDOW_UNREACHABLE,APP_NOT_ALLOWED,SIGN_IN_CANCELLED,SIGN_IN_UNAVAILABLE. - Back asks the window first: with unsaved measurements, the shopper confirms.
Sign-in
Section titled “Sign-in”Shoppers sign in inside the window (email and a 6-digit code), once per app. Sign-in through Custom Tabs with passkeys is coming soon.
Was this page helpful?
Thank you. We read every answer.