Android sdk: CustomEventInterstitial destroy() is never called

433 views
Skip to first unread message

pablosgh

unread,
Oct 4, 2013, 8:59:19 AM10/4/13
to google-adm...@googlegroups.com
Hi!

I'm developing some custom interstitials using the SDK version 6.4.1. The issue is that the destroy method of the CustomEventInterstitial implementations are never called, so I have no way to dispose the objects created.

The documentation says:

void destroy()
Tears down the custom event.

This is called at the end of the mediator's life cycle. The custom event is expected to release any resources and shut down.

This method is not guaranteed to be called. There are a number of reasons that this method can be skipped, such as a force close of the application.


I would like to know, if anyone knows, what are the reasons to skip this method or if there is a workaround to force the destroy.

Thanks,
Pablo

Eric Leichtenschlag

unread,
Oct 7, 2013, 11:51:40 PM10/7/13
to google-adm...@googlegroups.com
Hi Pablo,

Your custom event interstitial's destroy() will be called assuming your main activity calls adview.destroy(), which assumes your main activity's destroy() method is called. From the Activity Lifecycle, the onDestroy() method is killable, meaning the activity could be killed after onPause() before onDestroy() ever gets called, so it's possible not everything gets destroyed.

Thanks,
Eric

pablosgh

unread,
Oct 8, 2013, 8:14:35 AM10/8/13
to google-adm...@googlegroups.com
Hi Eric,

For the interstitials I don't have an AdView instance, which indeed has a destroy(). Instead, I'm using an InterstitialAd that has no destroy() method.
(The banners are destroyed correctly).

Am I getting it right?

Thanks,
Pablo

Eric Leichtenschlag

unread,
Oct 14, 2013, 4:14:34 PM10/14/13
to google-adm...@googlegroups.com
Hi Pablo,

May I ask what your custom event is trying to accomplish? Are you making a request to AdMob within your custom event? I just want to make sure you understand why you need to have an InterstitialAd object in your custom event.

The CustomEventInterstitial class provides you a destroy() method that you can override to allow you to clean up any resources you may have. You don't have to call interstitialAd.destroy() inside the destroy() method you override. AdMob knows that the interstitial is complete when it closes, so it knows when to perform the cleanup. So in the interstitial case, you could just leave that method blank.

Thanks,
Eric

pablosgh

unread,
Oct 15, 2013, 8:22:36 AM10/15/13
to google-adm...@googlegroups.com
Hi!

The custom event just loads the interstitial, shows it and should destroy it. I'm not making any request to AdMob inside the custom event, and don't have an InterstitialAd object in it. Isn't the InterstitialAd object the one who triggers the custom event when calling loadAd()? Why should the custom event need one?

That destoy() method is the one I wrote the documentation in the first message. I'm destroying the provider's object in it but is never called. That's the problem.

Thanks!
Pablo

Eric Leichtenschlag

unread,
Oct 22, 2013, 4:41:47 PM10/22/13
to google-adm...@googlegroups.com
Hi Pablo,

Thanks for the explanation - you're implementing the custom event correctly.

My next question is how are you requesting interstitials in the main part of your app? Are you creating a new InterstitialAd object every time, or calling loadAd on the same InterstitialAd object? I'm seeing the destroy() method being called in the latter case, but not the former case.

Thanks,
Eric

pablosgh

unread,
Oct 23, 2013, 9:54:01 AM10/23/13
to google-adm...@googlegroups.com
Eric!

That was the key! I was creating a new InterstitialAd to load a new interstitial. But there's still one case the destroy() is not called. I'm loading the interstitial when the Activity starts and showing it when the user does some interaction, if the user leaves the Activity without triggering the interstitial (calling to InterstitialAd show() method), the destroy() is not called.

Thanks for the tip!
Pablo
Reply all
Reply to author
Forward
0 new messages