Dash Stats Docs

Getting started

Integrate the AppBrain SDK in your app in 5 minutes, using these four simple steps:

1. Add Gradle dependency

In your project’s build.gradle file add:

repositories {
    maven {
        url 'http://swisscodemonkeys.github.io/appbrain-sdk/maven'
    }
}

dependencies {
    compile 'com.appbrain:appbrain-sdk:[email protected]'
}

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 completed a level in your game:

private InterstitialBuilder interstitialBuilder;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Preload the AppBrain interstitial.
    interstitialBuilder = InterstitialBuilder.create()
        .setAdId("MY-ADID") // This line is optional, but highly recommended.
                            // Create your AD ID under "Ad settings" for your publisher
                            // app on our dashboard.
        .setListener(new InterstitialListener() {
            @Override
            public void onAdLoaded() {}

            @Override
            public void onAdFailedToLoad(InterstitialError error) {}

            @Override
            public void onPresented() {}

            @Override
            public void onClick() {}

            @Override
            public void onDismissed(boolean wasClicked) {
                // Code that you want to run after the user has dismissed the interstitial
                // goes here.

                // Preload again, so we can use interstitialBuilder again.
                interstitialBuilder.preload(getContext());
                loadNextLevel();
            })
        .preload(this);
}

private void levelCompleted() {
    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 AppBrain SDK help pages.