XML Tag-Based Integration (Recommended)
This is the recommended approach for most use cases. Useandroid:tag attributes in your XML layouts and call applyStringbootTags() in your Activity.
XML Layout (activity_main.xml):
MainActivity.kt):
- Set
android:tag="string_key"on any TextView in XML - Call
binding.root.applyStringbootTags()in your Activity - All tagged TextViews automatically load strings from StringProvider
- UI updates automatically when language changes
Get String (Synchronous)
UseStringProvider.get() for synchronous string access. This method is NOT a suspend function and returns immediately from cache.
get()is synchronous (not suspend)- Returns immediately from cache
- Falls back to database if not in memory cache
- Returns
"??key??"if string not found - Can optionally fetch from network with
allowNetworkFetch = true
Reactive Flow for Auto-Updating UI
Use Kotlin Flow to reactively update UI when language changes or network sync completes.- Automatically updates when language changes
- Updates when network sync completes
- Lifecycle-aware (cancels when activity destroyed)
- Perfect for dynamic content
Complete Language Switching Pattern
Switch languages while maintaining smooth UI transitions and preventing content flashing.- Set locale with
setLocale() - Preload language to avoid UI flash
- Refresh from network (non-blocking)
- Restart Flow observations
- Re-apply tags to update all TextViews
- Save preference for next app launch
Get Available Languages
Retrieve available languages with automatic fallback to cached languages.- Server languages (fresh data)
- Cached language codes
- English-only fallback
FAQ Management
Load and display FAQs with tag-based filtering and optional language selection.Dynamic UI with sbTextView
Create dynamic TextViews that automatically load and update strings programmatically.- Loads strings from StringProvider automatically
- Updates when language changes
- Handles network fetch and caching
- Provides fallback text
Language Switching Extension
Simple activity-level extension for quick language switching.Preload Language for Fast Access
Warm up the cache synchronously to ensure instant string access.Get String Count and Cache Stats
Monitor cache performance and debug string availability.A/B Testing Integration
SDK v1.2.0+ includes built-in A/B testing support. The SDK automatically:- Generates or uses a persistent device ID for consistent experiment bucketing
- Receives experiment assignments from the backend (V2 API)
- Delivers the correct variant strings to users
- Integrates with your analytics platform (Firebase, Mixpanel, Amplitude, etc.)
How It Works
- Device ID: SDK generates a UUID per installation (or uses your app’s device ID)
- X-Device-ID Header: Sent with every API request
- Backend Assignment: Server assigns device to experiment variants based on device ID
- String Resolution: SDK receives pre-resolved strings for assigned variants
- Analytics Tracking: SDK notifies your analytics handler of experiment assignments