Skip to main content

Android Examples

Code examples for the current Azeoo SDK flow: initializeconnectUser → 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.initialize(
context = this,
apiKey = "your-sdk-api-key",
config = AzeooConfig(
locale = "en",
analyticsEnabled = true,
offlineEnabled = true,
),
callback = { error ->
if (error != null) {
// Handle initialization error
}
},
)
}
}

Connect and show a module

// After user login
AzeooSDK.shared.connectUser(
token = "user-token",
gender = "male",
height = AzeooHeight(178.0),
weight = AzeooWeight(75.0),
) { _, connectError ->
if (connectError == null) {
// 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.btnScanner).setOnClickListener {
AzeooSDK.shared.modules.nutrition.showScanner()
}

User and theme

AzeooSDK.shared.user.getProfile { profileResult ->
profileResult.onSuccess { profile -> /* use profile */ }
}
AzeooSDK.shared.theme.setDarkMode { result ->
result.onFailure { error -> /* handle error */ }
}
AzeooSDK.shared.disconnect { error ->
if (error == null) {
// 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