Android SDK
Android SDK - Configuration
Configure the FunnelMob Android SDK.
Using Builder (Recommended)
import com.funnelmob.sdk.FunnelMobConfiguration
import com.funnelmob.sdk.FunnelMobConfiguration.LogLevel
val config = FunnelMobConfiguration.Builder(
apiKey = "fm_live_abc123" // Required: Your API key
)
.logLevel(LogLevel.NONE) // NONE, ERROR, WARNING, INFO, DEBUG, VERBOSE
.flushInterval(30_000L) // Auto-flush interval in ms (min: 1000, default: 30000)
.maxBatchSize(100) // Events per batch (1-100, default: 100)
.build()
FunnelMob.initialize(this, config)Using Data Class (Kotlin)
val config = FunnelMobConfiguration(
apiKey = "fm_live_abc123",
logLevel = LogLevel.NONE,
flushIntervalMs = 30_000L,
maxBatchSize = 100
)Application Class Setup
import com.funnelmob.sdk.FunnelMob
import com.funnelmob.sdk.FunnelMobConfiguration
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val config = FunnelMobConfiguration.Builder(
apiKey = "fm_live_abc123"
).build()
FunnelMob.initialize(this, config)
}
}SDK Control
// Disable tracking (e.g., for GDPR compliance)
FunnelMob.setEnabled(false)
// Re-enable tracking
FunnelMob.setEnabled(true)
// Force send queued events immediately
FunnelMob.flush()Error Handling
The SDK throws IllegalStateException if used before initialization:
try {
FunnelMob.trackEvent("test")
} catch (e: IllegalStateException) {
Log.e("FunnelMob", "SDK not initialized: ${e.message}")
}Validation errors are logged. Set logLevel to see them:
val config = FunnelMobConfiguration.Builder("fm_live_abc123")
.logLevel(LogLevel.DEBUG)
.build()