We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I use Admob and I would like to implement an adListener function on my application. The ads are actually correctly working. But after several test and modification, the code just can't work (there is a compiling error) with this line :
Here is the documentation of this code.
The questions are:
-does anyone has done this in the PDE before?
-If not, how could I do to implements the interface AdListener and use it with
adView.setAdListener(AdListener adListener); ?
-Is there an other way to detect when a clic have been done on the adMob ad?
You are delving into some advanced Java concepts that it seems you aren't quite ready for yet. In short, the base class for all Processing sketches,
PAppletdoes not implement
AdListener(this is similar to extension for inheritance, but there are differences). When you call
adView.setAdListener(this), AdMob expects
PApplet-based Processing sketch) to implement
AdListener, which it does not. Although it is possible to make your sketch implement
AdListener, it is probably easier to go the anonymous class route (this code taken from the link you provided...):
You may run into problems going down this route (such as "Variable x isn't
final", or something like that). If this is the case, then you can create a separate listener class. For now, I'll leave this solution because it is more concise and easier to pull off than the other solution.
Thanks again calsign :) Unfortunately, the code you gave me make an error. I've also tried to make a separate adListener class:
And the setAdListener inside of
The first part can compile easily, but not the second. Am I missing something? Thanks !
This method is a bit more complicated. I'll try to spare you the gory details:
This method should avoid errors about
finalvariables. However, if this is not your error, then there is something else going wrong...
I'm afraid something else is going wrong :/
And I just saw that I gave you the wrong 1st link, you should go on : "6.4.1 and earlier SDK" section.I guess it will help ( :-S ). Here is what I have:
Theses lines compile fine, contrary to this:
Thanks for helping, calsign ^^
I must say I'm not a smart guy !
I followed your recommendations with the 6.4.1 SDK section, and it worked ! here is what I wrote:
The rest in onCreate is exactly the same. Thanks for all calsign, I owe you a lot :)