Getting started
Integrate the AppBrain SDK in your app in 5 minutes, using these three simple steps:
1. Add Gradle dependency
Add the dependency to your app module’s build file:
// build.gradle.kts
dependencies {
implementation("com.appbrain:appbrain-sdk:+")
}
Using Groovy? implementation 'com.appbrain:appbrain-sdk:+'. The + keeps you on the latest SDK; pin
a version (e.g. 18.20) if you prefer. See SDK setup for full details.
2. Access your account
If you haven’t done so yet, create an AppBrain developer account to get access to the AppBrain developer dashboard and to register your app for the SDK.
3. Show ads
Show an interstitial ad with InterstitialBuilder, for example when the user completes a level in
your game:
private lateinit var interstitialBuilder: InterstitialBuilder
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Preload the AppBrain interstitial. Setting the AdId is optional but highly
// recommended. You can also create a custom AdId for your app on our dashboard
// under "Ad settings".
interstitialBuilder = InterstitialBuilder.create()
.setAdId(AdId.LEVEL_COMPLETE)
.setOnDoneCallback {
// Preload again, so we can use interstitialBuilder again.
interstitialBuilder.preload(this)
loadNextLevel()
}
.preload(this)
}
fun onLevelCompleted() {
interstitialBuilder.show(this)
}
For more details and examples, see ad unit overview.
You’re done! For more detailed instructions see SDK setup, or the rest of the SDK documentation help pages.