Aller au contenu principal

Android Examples

Code examples for the current Azeoo SDK flow: initconnect → use modules and user / theme.

Application setup

import android.app.Application
import com.azeoo.sdk.AzeooConfig
import com.azeoo.sdk.AzeooSDK

class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
AzeooSDK.init(
context = this,
apiKey = "your-api-key",
config = AzeooConfig(
locale = "en",
analyticsEnabled = true,
offlineEnabled = true,
),
)
}
}

Connect and show a module

// After user login
AzeooSDK.shared.connect(userId = "user-123", token = "jwt-token") { result ->
result.onSuccess { profile ->
// Wait for SDK ready if needed
AzeooSDK.onReady { readyResult ->
readyResult.onSuccess {
supportFragmentManager.beginTransaction()
.replace(R.id.container, AzeooSDK.shared.modules.nutrition.getFragment())
.commit()
}
}
}
}

Activity: buttons to open screens

findViewById<Button>(R.id.btnDiary).setOnClickListener {
AzeooSDK.shared.modules.nutrition.showDiary(null)
}
findViewById<Button>(R.id.btnTraining).setOnClickListener {
AzeooSDK.shared.modules.training.showWorkouts()
}
findViewById<Button>(R.id.btnScanner).setOnClickListener {
AzeooSDK.shared.modules.nutrition.showScanner()
}

User and theme

val profile = AzeooSDK.shared.user.getProfile()
AzeooSDK.shared.theme.setDarkMode()
AzeooSDK.shared.disconnect { /* user logged out */ }

Full example app

See the example/android project in the repository for a complete app with login, bottom navigation, and SDK integration.

Next steps