3

I'm thinking of integrating Leadbolt (or Tapjoy) to my Libgdx game. I want to make a store based on the clicked forms. More click - more stuff from the store for the user. I found Leadbolt and Tapjoy. These ad providers are providing direct helps for these stuffs. I have take a look on the Leadbolt integrating guide. I have a problem with it. It needs me to pass a context to the AdController. I don't know if it possible in any way to pass the context for the AdController or not, so I would like to ask you about it, that how can I do, if I can. (I haven't tried it in Libgdx yet, but with the superjumper example had problem too, when I wanted to pass a context for something, and I think because the Libgdx app don't extends an Activity, it will have problems too.)

Here is the sample code from Leadbolt:

AdController myControllerForm = new AdController(this, "MY_LB_ID", new AdListener() {
           public void onAdProgress() {}
           public void onAdLoaded() {
                     myControllerForm.hideAd();
           }
           public void onAdFailed() {
                     launchMain();
           }
           public void onAdCompleted() {
                     myControllerForm.hideAd();
                     launchMain();
           }
           public void onAdClosed() {
                     launchMain();
           }
           public void onAdClicked() {}
           public void onAdAlreadyCompleted() {
                     launchMain();
           }
           public void onAdHidden() {
                     launchMain();
           }
       });
           myControllerForm.setAsynchTask(true);
           myControllerForm.loadAd();
   }

public void launchMain()
           {
                 finish();
                 startActivity(new Intent(Splash.this, MainApp.class));
            }
}

The class extends Activity, and the methods are in the onCreate() method in this example.

If you have integrated the Leadbolt or Tapjoy to your Libgdx game, then could you please give me a code about how did you do it?

Thanks in advance!

Zwiebel
  • 1,605
  • 4
  • 21
  • 37

2 Answers2

5

LibGDX actually extends AndroidActivity (by AndroidApplication, which extends AndroidActivity).

If you setup your project correctly, you can access it from "Android starter" project. This is also the only place, where you can play with ads, because "Desktop starter" in no way extends AndroidActivity.

Here's also adMob tutorial, which you may find useful (creating overlaying views).

This is all info I can give you, as I don't know whether you want to display your ads always, reload them as time passes or just hide them after particular events. In such cases, you might want to implement your custom interfaces.

Good luck!

lucian.pantelimon
  • 3,673
  • 4
  • 29
  • 46
Mithras
  • 268
  • 1
  • 8
  • Thanks, but in my opinion it is something else, because I don't need to show or hide banner (I want to integrate capture forms). I only need to show a capture form when a user clicks on a button. And then if he filled it, put him back to the previous screen. – Zwiebel Jun 15 '12 at 11:50
  • I understand that it can be accessed only from the AndroidApplication (I haven't got any AndroidApplication class just Game for the base - is it good too? ) – Zwiebel Jun 15 '12 at 11:51
3

Check out the libGDX tutorial on AdMob: http://code.google.com/p/libgdx/wiki/AdMobInLibgdx

Skip the stuff at the top about setting up AdMob, I think you need the part in the "Control" section which talks about getting events from your generic libGDX code (which has to also run on the desktop) into your Android-specific code (for example to show an ad). The general way is to define your own interface (see the IActivityRequestHandler in the AdMob tutorial), and pass an object that implements that interface into your libGDX code. On the desktop this object would do nothing, and on the Android side you can use all the standard Android code to do the right thing.

P.T.
  • 24,557
  • 7
  • 64
  • 95
  • Thanks! I will try to do it, but I would like to ask you that how can I show/hide the capture form? Because there is nothing like adview what I can hide. There are methods only. Or need I to do something with the myControllerForm.loadAd()? Because I can't imagine that how can I "control" it. – Zwiebel Jun 15 '12 at 18:48
  • I've been trying to add AdMob to Libgdx and found this thread. i followed the tutorial you mentioned put i dont understand what i should be passing to the Libgdx code. help is appreciated – Hamzah Malik Dec 06 '13 at 20:46