Re: Custom event with Admob java.lang.NullPointerException.

475 views
Skip to first unread message

Eric Leichtenschlag

unread,
Jul 13, 2012, 1:00:08 PM7/13/12
to google-adm...@googlegroups.com
Hey Adam,

When configuring your custom event, you'll need to provide a fully qualified class name (ex: com.adam.MyCustomEvent).  Then when AdMob Mediation chooses your custom event network, it will invoke requestBannerAd on the class you configured.  The parameter field would contain the id necessary to request a leadbolt ad.  For example, if your custom event implemented AdMob, you'd put the publisher ID as your parameter, and your custom event class would use that parameter to create the AdView and load an ad.

We have an in-depth walk-through of how to implement a custom event here.  Check this out and let me know if this doesn't answer your questions.

Cheers,
Eric


On Wed, Jul 11, 2012 at 6:29 AM, Adam Zenaty <aze...@integralicons.com> wrote:

I am creating  custom even admob mediation with leadbolt on android

i created my custom class implementing custom event banner

 but i don't know how to call my custom class and what is the parameters that i need when i

call requestBannerAd method.
 



--


Eric Leichtenschlag

unread,
Jul 17, 2012, 9:09:34 PM7/17/12
to google-adm...@googlegroups.com
Hey Ari,

1. Calling adView.destroy() can be helpful to clean up the AdView and fix some bugs on old versions of Android, but it is not necessary.  Actually, the custom events don't get notified when they get destroyed.  I've added a feature request to add a destroy method to the CustomEventBanner interface.
2. When invoking the banner listener's onReceiveAd method, (such as this.bannerListener.onReceivedAd(this.adView); ), the AdMob SDK will add the view you pass in.  So you don't need to do this yourself.

Cheers,
Eric


On Mon, Jul 16, 2012 at 1:59 PM, Ari <ari...@gmail.com> wrote:
Hi Eric,

I noticed a couple differences between the admob request in the custom event tutorial and the basic admob integration here:
https://developers.google.com/mobile-ads-sdk/docs/android/fundamentals.

1 - Isn't a call to adView.destroy() required at some point for the custom event?
2 - Shouldn't the adView be added to the layout in the custom event (layout.addView(adView);)?

It seems like you can add the layout.addView(adView) to the custom event's
requestBannerAd method but you would need an onDestroy method in CustomEventListener or something.

Thanks,
Ari



Adam Zenaty

unread,
Jul 23, 2012, 5:37:16 AM7/23/12
to google-adm...@googlegroups.com
i did all of this
but my question should i create an object from my custom class or it is called automatically

another thing could you send me a sample code.

thank you in advance

Eric Leichtenschlag

unread,
Jul 23, 2012, 1:32:07 PM7/23/12
to google-adm...@googlegroups.com
Hey Adam,

The SDK will automatically call the requestBannerAd() method of your custom class that implements CustomEventBanner.

This page should provide all the sample code necessary to get up and running.  In requestBannerAd(), you'll want to create a leadbolt ad view and make an ad request on that adview.  Then, assuming leadbolt has an event listener, you would implement their event listener; when an ad is receieved, you'd invoke this.bannerListener.onReceivedAd(this.adView), where adView is the leadbolt ad view.

Eric

--
 
 
  


ari L

unread,
Jul 28, 2012, 3:20:16 PM7/28/12
to google-adm...@googlegroups.com
Yes leadbolt has to have its own event listeners to know when the ad is clicked/loaded. Then you can do something like

          LeadboltWhatever adView = new LeadboltWhatever(activity, serverParameter);

 adView.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                try {
                  listener.onClick();
                  listener.onLeaveApplication();
                } catch (Throwable t) {
                    // Something went wrong, oh well.
                  }
                }
              });


   adView.setOnAdFailedListener(new OnAdFailedListener (){
              public void onAdFailed(LeadboltWhatever adView){
                  listener.onFailedToReceiveAd();
              }
          });
          adView.setOnAdLoadedListener(new OnAdLoadedListener (){
              public void onAdLoaded(LeadboltWhatever adView){
                  listener.onReceivedAd(adView);
              }
          });
          adView.loadAd();


Where OnAdLoadedListener, OnAdFailedListener, OnClickListener are LEADBOLT objects from their sdk.
See here for callbacks example: https://developers.google.com/mobile-ads-sdk/docs/android/mediation/

--
 
 
 

Eric Leichtenschlag

unread,
Jul 30, 2012, 1:10:07 PM7/30/12
to google-adm...@googlegroups.com
Ari's code looks good.  I would also recommend putting listener.onPresentScreen(); inside of the LeadBolt click listener.


--
 
 
  


Reply all
Reply to author
Forward
0 new messages