Skip to main content

Android Integration Guide

This guide walks through integrating the Azeoo SDK into your Android app using the initialize → connect flow.

Overview

  1. InitializeAzeooSDK.initialize(context, apiKey, config, theme, ...) in your Application (no user).
  2. ConnectAzeooSDK.shared.connectUser(token, gender, height, weight, callback) when you have a user token.
  3. Use modulesAzeooSDK.shared.modules.nutrition, then embed fragments or call module methods.

Basic Integration

Step 1: Initialize the SDK

In your Application class:

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

class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
AzeooSDK.initialize(
context = this,
apiKey = "your-sdk-api-key-here",
config = AzeooConfig(locale = "en", analyticsEnabled = true, offlineEnabled = true),
theme = AzeooThemeConfig(),
callback = { error ->
if (error == null) {
// SDK initialized
} else {
// Handle init error
}
}
)
}
}

Register your Application in AndroidManifest.xml:

<application android:name=".MyApplication" ...>
</application>

Step 2: Connect a user

When the user is logged in, call connectUser:

AzeooSDK.shared.connectUser(
token = "user-token",
gender = "male",
height = AzeooHeight(178.0),
weight = AzeooWeight(75.0),
) { profile, error ->
if (error == null) {
Log.d("AzeooSDK", "Connected: ${profile?.id}")
} else {
Log.e("AzeooSDK", "Connect failed", error)
}
}

Step 3: Use SDK UI

In an Activity or Fragment, use the modules after the SDK is ready:

import com.azeoo.sdk.AzeooSDK

if (AzeooSDK.isReady) {
val nutritionFragment = AzeooSDK.shared.modules.nutrition.getFragment()
// Add fragment to your container, or use modules.nutrition.showDiary() etc.
}

Complete example

import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.azeoo.sdk.AzeooHeight
import com.azeoo.sdk.AzeooSDK
import com.azeoo.sdk.AzeooWeight

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

AzeooSDK.shared.connectUser(
token = "user-token",
gender = "male",
height = AzeooHeight(178.0),
weight = AzeooWeight(75.0),
) { _, error ->
if (error == null && AzeooSDK.isReady) {
findViewById<Button>(R.id.btnNutrition).setOnClickListener {
AzeooSDK.shared.modules.nutrition.showDiary(null)
}
} else {
Log.e("AzeooSDK", "Connect failed", error)
}
}
}

override fun onDestroy() {
super.onDestroy()
AzeooSDK.shared.dispose()
}
}

Error handling

Handle init and connect errors:

AzeooSDK.shared.connectUser(
token = userToken,
gender = gender,
height = height,
weight = weight,
) { _, error ->
if (error != null) {
Log.e("AzeooSDK", "Connect failed", error)
showError("Could not connect to SDK")
}
}

Next steps