Leadbolt Interstiltial support for Android

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
4aiman
Party member
Posts: 262
Joined: Sat Jan 16, 2016 10:30 am

Leadbolt Interstiltial support for Android

Post 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.
Last edited by 4aiman on Thu Feb 25, 2016 5:30 pm, edited 1 time in total.
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Leadbolt Interstiltial support for Android

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests