Search code examples
leadbolt

Implementing more than one interstitial ad in android app


I want to implement more than one ad in my app. How can I do it? I have added an ad from the LeadBolt page but I'm unsure of the code to add to my application.

Is there a way to add a second ad or refresh the current ad every 30 to 60 seconds?

Here is my code:

 private void initializeLeadBolt() {
    audioad = new AdController(act, "YOUR_LB_AUDIO_ID");
    audioad.loadAudioAd();
    AppTracker.startSession(act, "YOUR_....", new AppModuleListener() {
        @Override
        public void onModuleLoaded() {
        }

        @Override
        public void onModuleFailed() {
            loadDisplayAd();
        }

        @Override
        public void onModuleClosed() {
        }

        @Override
        public void onModuleCached() {
        }
    });
}

private void loadDisplayAd() {
    // use this else where in your app to load a Leadbolt Interstitial Ad
    interstitial = new AdController(act, "");
    interstitial.loadAd();
}

public void onPause() {
    super.onPause();
    if (!isFinishing()) {
        AppTracker.pause(getApplicationContext());
    }
}

public void onResume() {
    super.onResume();
    AppTracker.resume(getApplicationContext());
}

public void onDestroy() {
    super.onDestroy();
    if (isFinishing()) {
        AppTracker.closeSession(getApplicationContext(), true);
    }
    if (audioad != null) {
        audioad.destroyAd();
    }
    if (interstitial != null) {
        interstitial.destroyAd();
    }

Solution

  • Assuming you are using the Leadbolt SDK to display ads...

    To display another Leadbolt Ad, simply initialize a new AdController instance using the newly created section id, for example:

    AdController interstitial2 = new AdController(act, “LB_INTERSTITIAL_SECTION_ID”);
    interstitial2.loadAd();