Page 1 of 1

Leadbolt Interstiltial support for Android

Posted: Tue Feb 23, 2016 8:33 pm
by 4aiman
So, there is a topic about AdMob support...
But I don't use AdMob mainly because of the ways it provides me to get my money.

I'm not here to advertise anything but to give back and share with what I've learned.
Note that I don't use banners yet, so no support for those.

I'm also aware that one can integrate many ads SDKs using AdMob account, but I didn't want another "proxy" which probably will claim it's share... I'm just to lazy to setup another integration. :)



So...
What one will need to achieve interstitial from Leadbolt:

1. Register an account at Leadbolt
2. Get Leadbolt's SDK
3. Copy AppTracker.jar from the SDK to the "libs" folder of your project
4. Integrate google_services_lib into your project (can be a little bit tricky, but it's better to get how to do it on one's own)
5. Follow this thread to add methods for Interstitials support from AdMob
6. Change the "src/GameActivity.java" file a bit:

a) Inside "onCreate" after "getWindowManager().getDefaultDisplay().getMetrics(metrics);" add this:

Code: Select all

    // Leadbolt  Intestitial  -- got from https://help.leadbolt.com/android-integration-guide/
    if(savedInstanceState == null) {
            // Initialize Leadbolt SDK with your api key
            AppTracker.startSession(getApplicationContext(),"<ads ID>");
        }
        // cache Leadbolt Ad without showing it
        AppTracker.loadModuleToCache(getApplicationContext(),"inapp");
b) Change the "isInterstitialLoaded" method to look like this

Code: Select all

      public boolean isInterstitialLoaded() {
            Log.d("GameActivity", "Calling isInterstitialLoaded");
            adLoaded = AppTracker.isAdReady("inapp");
            return adLoaded;            
         }

c) Change the "showInterstitial" method to look like this

Code: Select all

         public void showInterstitial() {
            Log.d("GameActivity", "Showing ad!");
            if(AppTracker.isAdReady("inapp")) {
                  AppTracker.loadModule(getApplicationContext(),"inapp");
            }
         }
After that one should be able to call

Code: Select all

love.system.showInterstitial()
to display interstitiall.
It may well be that I've coded something/most/all in a wrong way, but hey! I'm not a java programmer and the code above is working for me ;)

Any criticism on the code is welcomed.

Re: Leadbolt Interstiltial support for Android

Posted: Wed Feb 24, 2016 4:28 am
by bobbyjones
You should have posted this in the main forum. The Android subforum was archived for this reason. Also this gives me a pretty neat idea for a project.