Android integration
Basic Setup
2
Initialize SDK
import android.app.Application
import tools.amply.sdk.Amply
import tools.amply.sdk.config.amplyConfig
class MyApplication : Application() {
lateinit var amply: Amply
private set
override fun onCreate() {
super.onCreate()
val config = amplyConfig {
api {
appId = "your.app.id"
apiKeyPublic = "your_public_key"
apiKeySecret = "your_secret_key"
}
}
amply = Amply(config, this)
}
companion object {
fun getAmply(context: Context): Amply {
return (context.applicationContext as MyApplication).amply
}
}
}Configuration Options
Full Configuration
val config = amplyConfig {
api {
appId = "your.app.id"
apiKeyPublic = "your_public_key"
apiKeySecret = "your_secret_key"
}
// Optional: Default campaign configuration (JSON string)
defaultConfig = """{"campaigns": []}"""
// Optional: Override endpoints for development
network {
configBaseUrl = "https://config.amply.tools"
backendBaseUrl = "https://api.amply.tools"
}
}Tracking Events
Basic Events
From Activities/Fragments
From Compose
Handling Deep Links
Register Listener
Handle in Activity
System Events
Rate & Review
Retrieving Data
Get Dataset Snapshots
Get Recent Events
Permissions
Advertising ID (Optional)
Best Practices
Troubleshooting
Last updated