Request: add official way to preload all kinds of ads (including banner ads), with Context of ApplicationContext

1,623 views
Skip to first unread message

Liran Barsisa

unread,
Jun 22, 2023, 7:03:43 AM6/22/23
to Google Mobile Ads SDK Developers
Currently it's available only for native ads, and even then when I spoke with Admob support, they were kinda against it as I use ApplicationContext .

Thing is, the preloading and caching isn't guaranteed to be in some Activity.
Sometimes things are loaded just before, even in a Service, such as loading before showing on a new Activity or even on a floating UI (using system-alert-window permission).
Sometimes it could be nice to move the ad from one place to another. 

Please offer a way to preload and cache ads of all kinds.
This includes Banner ads too.

Mobile Ads SDK Forum Advisor

unread,
Jun 23, 2023, 10:51:31 AM6/23/23
to lbl...@gmail.com, google-adm...@googlegroups.com

Hi,

Thank you for reaching out to us.

With regard to your concern for preloading ads, this was previously raise to us on this forum thread (https://groups.google.com/g/google-admob-ads-sdk/c/OAGAtvMJyXE/m/pw76y7nOAgAJ), and one of our wider team mentioned the following information below.

"The guidance from https://groups.google.com/g/google-admob-ads-sdk/c/BuczXZG9AeU still stands - AdMob and Ad Manager use a 1px impression definition for all network/backfill based ads, so an impression isn't counted until the ad is shown.

For preloading, after roughly an hour, the server may consider the ad "expired" and not count the impression, even if an impression ping is sent from the client. This is only documented on native ads today (https://developers.google.com/admob/android/native/start#when_to_request_ads) but applies similarly to all formats. I will say though, that generally you shouldn't need to preload banners for an hour. Unlike full screen ads which need to be preloaded because the user experience changes drastically on show, and you need to have an ad ready for the show opportunity, banner space can be reserved and the ad can come in whenever. For a feed style app, you may preload some banners so they show up in the feed loaded, but that may only be on the order of seconds or maybe a few minutes that you'd need to preload.

If you're preloading a banner for an hour, perhaps reconsider if there's a better point in time you could preload that banner so that it doesn't need to be an hour, or a different place to show that banner. Also note that banner ads will reload (assuming you set a refresh rate) once on screen, so even if the first banner impression gets discounted, refreshes would happen if the banner is on screen long enough, and impressions from the refreshes would get counted for the next ~hour."

Let us know if this is what you're looking for. If not, kindly provide us more information and examples for your use case so we can provide proper guidance for it.

This message is in relation to case "ref:_00D1U1174p._5004Q2mWO1y:ref"

Thanks,
 
Google Logo Mobile Ads SDK Team


Liran Barsisa

unread,
Jun 24, 2023, 3:12:11 AM6/24/23
to Google Mobile Ads SDK Developers
1. Are you saying it's now possible to preload AdView? You wrote "you may preload some banners" .
The request is to add official support for it, as I can't find the API.
Please show me the API to do it.

2. On the link you've provided, it says "Preloading banners, on the other hand, is a violation of AdMob policy.  Every time your app requests a banner, it's expected to display that banner to the user immediately on receiving it. Otherwise, advertisers can be charged for ads that are never shown."
Later it says "So i can preload my native advanced ads and banner ads now?...Yes, you may.  We have an example that loads banner ads for a RecyclerView at..."
Checking out the sample, I don't see it preloads anything. It just reaches the AdView and loads there the ads, like normal load&show behavior.
The sample is very outdated. Can you please offer an updated one which preloads completely in the background (no need for Activity instance) ? Maybe in the official samples , together with native ads preloading?

3. What do you mean by "1px impression definition for all network/backfill based ads"?

4. As for "banner space can be reserved and the ad can come in whenever", this is what the company wants to avoid, because it's a worse user experience. They want to have the ad being shown right away when possible, using preloading before reaching the UI that has it.
When using native ads, it's possible to preload in the background before reaching Activity, but for AdView there is no official API. 

My request is to offer it for all, and also make sure that ApplicationContext can be use and not just Activity (which might lead to memory leaks, BTW).

Mobile Ads SDK Forum Advisor

unread,
Jun 26, 2023, 6:57:27 AM6/26/23
to lbl...@gmail.com, google-adm...@googlegroups.com
Hello Liran,

To answer your concerns:

1. Are you saying it's now possible to preload AdView? You wrote "you may preload some banners" .
The request is to add official support for it, as I can't find the API.
Please show me the API to do it.

2. On the link you've provided, it says "Preloading banners, on the other hand, is a violation of AdMob policy.  Every time your app requests a banner, it's expected to display that banner to the user immediately on receiving it. Otherwise, advertisers can be charged for ads that are never shown."
Later it says "So i can preload my native advanced ads and banner ads now?...Yes, you may.  We have an example that loads banner ads for a RecyclerView at..."
Checking out the sample, I don't see it preloads anything. It just reaches the AdView and loads there the ads, like normal load&show behavior.
https://github.com/googlearchive/android-ads/blob/master/advanced/BannerRecyclerViewExample/app/src/main/java/com/google/android/gms/example/bannerrecyclerviewexample/MainActivity.java#L132
The sample is very outdated. Can you please offer an updated one which preloads completely in the background (no need for Activity instance) ? Maybe in the official samples , together with native ads preloading?

3. What do you mean by "1px impression definition for all network/backfill based ads"?
  • This means that impressions are counted when the first pixel of an ad is displayed on screen.

4. As for "banner space can be reserved and the ad can come in whenever", this is what the company wants to avoid, because it's a worse user experience. They want to have the ad being shown right away when possible, using preloading before reaching the UI that has it.
When using native ads, it's possible to preload in the background before reaching Activity, but for AdView there is no official API. 

Liran Barsisa

unread,
Jun 26, 2023, 7:40:10 AM6/26/23
to Google Mobile Ads SDK Developers
1. Please offer an API for this. This is the request here.
AdView is much easier to maintain than native ads, so it would be great to have an official way to preload ads. 
2. You said there is no API, so how can there be a sample to demonstrate the API? I've checked the samples and I don't see one that has preloading as I've described.
3. I see. What about preloading? Is there a limit about it? If the app preloads but eventually doesn't show the ad due to certain conditions, is it ok? I think it's considered something that will lead to less revenue and less times of even getting ads, eventually, no?

4. We already have native ads, and we use AdView as a fallback if it fails or if we decide it's better.
Is there any difference in terms of revenue for one over the other?

Mobile Ads SDK Forum Advisor

unread,
Jun 26, 2023, 3:01:03 PM6/26/23
to lbl...@gmail.com, google-adm...@googlegroups.com

Hi Liran,

Thank you for your response.

To provide more information to the following concern related to preloading, let us share this to the wider team. Rest assured that one of our team will reach out to you.



This message is in relation to case "ref:_00D1U1174p._5004Q2mWO1y:ref"

Mobile Ads SDK Forum Advisor

unread,
Jun 26, 2023, 7:34:18 PM6/26/23
to lbl...@gmail.com, google-adm...@googlegroups.com

Hi Liran,

 

My name is Nick and I will be helping you with your ad preload concerns. I understand you want to preload ads using the ApplicationContext. At this time we do not support loading full screen ads from the ApplicationContext. All ads must be loaded from an ActivityContext, there are a few reasons for this, including integration with partners which may not support ApplicationContext.

 

Hope this helps,

Nick



ref:_00D1U1174p._5004Q2mWO1y:ref

Liran Barsisa

unread,
Jun 27, 2023, 2:20:16 AM6/27/23
to Google Mobile Ads SDK Developers

I didn't say "full screen ads". I said all ads. This includes AdView too.
It was said that it's possible, but there is no sample and there is no API that I can find to do it.
Please make it have support for all.

Liran Barsisa

unread,
Jun 27, 2023, 2:22:24 AM6/27/23
to Google Mobile Ads SDK Developers
The link you've provided is from 2015. Nothing has changed since?
Why would advertisers need Activity for preloading? They shouldn't care when and how the ad is preloaded. They should care that the ad is shown and people reach it.
Please improve the SDK.

Also, it doesn't mention AdView, which I'm interested in and as I saw that it should be possible.


Liran Barsisa

unread,
Jun 27, 2023, 6:40:14 AM6/27/23
to Google Mobile Ads SDK Developers
In addition, setting Activity instance to preload an ad can actually lead to memory leak, because if the Activity is closed before the ad was loaded, the ad is still holding a reference to it, which it shouldn't.
Please improve the SDK to support preloading of ads, no matter the Context.
If Context was important to be Activity, it would have been Activity and not the general Context class.
So far I haven't noticed any issue on native-ads related to preloading ads using Application. 
It can even be useful for ViewModel, which doesn't have a reference to Activity. 

Mobile Ads SDK Forum Advisor

unread,
Jun 27, 2023, 1:10:21 PM6/27/23
to lbl...@gmail.com, google-adm...@googlegroups.com

Hi Liran,

Thank you for your suggestion regarding using the Application Context. For the memory leak, if you have a sample application demonstrating a memory leak we will take a look.

 

Thanks,
Nick



ref:_00D1U1174p._5004Q2mWO1y:ref
Message has been deleted

Liran Barsisa

unread,
Jul 4, 2023, 9:42:37 AM7/4/23
to Google Mobile Ads SDK Developers
Nick, please check the other samples that I've shown, based on your sample. It's not all on native ads. It's the same issue for other types.
The scenario is the same, but if you really want to import anything, it's still on the same Github repository:
https://github.com/AndroidDeveloperLB/AdmobSample

Please check the same scenario with each type of ad.
And, please offer true preloading, which doesn't assume the type of Context, allows loading in the background no matter what, and later allows to show the ad (if succeeded) on any type of UI (including floating UI).

Mobile Ads SDK Forum Advisor

unread,
Jul 6, 2023, 9:31:56 AM7/6/23
to lbl...@gmail.com, google-adm...@googlegroups.com

Hi Liran,

I'm covering for Nick who is away this week. Generally we haven't recommended ApplicationContext because ads create WebViews and generally it's an Android best practice to create View objects with an Activity context. But we are still discussing internally on challenging that understanding, as we understand your intent is precisely to have the ads and its WebView live past the lifecycle of an Activity.

Beyond that, it's unclear to me if this thread and the thread at https://groups.google.com/g/google-admob-ads-sdk/c/DPG1ej52N3A are duplicates or have different questions. Is this the same topic where you are essentially asking us to approve use of ApplicationContext, and then once we do that, show use of that in samples?

Thanks,
Eric, Mobile Ads SDK Team

ref:_00D1U1174p._5004Q2mWO1y:ref

Liran Barsisa

unread,
Jul 9, 2023, 9:19:13 AM7/9/23
to Google Mobile Ads SDK Developers
Indeed.
And I've tested an app that does what I said: preload the ad (both native ads and even banner ads) before an Activity is used:
https://play.google.com/store/apps/details?id=com.truecaller
This is an app with more than 1,000,000,000 downloads, so you see how important such a thing is.
I can prove it by looking at the logs vs what's shown on the device. 
It loads the ads while SAW is used during a phone call (a floating UI might be shown to mention who's calling), meaning there is no Activity at all. 
Then later, after the phone call has ended, an after-call UI is shown with the ad being shown right away (if succeeded loading).

I'm sure there are plenty of other apps that cache ads outside of Activity, and not just this one.
My request is to have an official way to do it .
And if you insist that such a thing should be banned, you shouldn't have "Context" and you should only have "Activity", and you should also monitor apps that try to overcome this in some way (such as perhaps faking an Activity somehow).

As for the other thread, it's about memory leaks, which I've found even on the samples. 
There, the main scenario I've tested is to take any sample of showing ads, add an Activity before the main one and make it the new main one, start the app, let it reach both the new main activity and then the old one, show the ad, and go back to the newly created Activity. It showed there is a memory leaks.
It happened for multiple types of ads, and at least for native ads, I suggested to use ApplicationContext as it makes more sense and it seems to have fixed the issue.
Currently, the only sample that the Admob seems to have fixed is the native ads. Not the others that I've mentioned and showed.
I wrote more there and in the emails conversation , but I forgot.

Mobile Ads SDK Forum Advisor

unread,
Jul 11, 2023, 12:23:07 PM7/11/23
to lbl...@gmail.com, google-adm...@googlegroups.com
Hi Liran,

Thank you for the additional context. Let me sync with my team and I will get back to you when I have further details.

Liran Barsisa

unread,
Jul 11, 2023, 1:46:31 PM7/11/23
to Google Mobile Ads SDK Developers
Any news about this?
The preloading of ads should be possible for all kinds of ads, no matter where in the code I request it.
As long as there is no official way to do it, no documentation to tell about it, and no even restriction in the parameter itself as it's just "Context" and not "Activity", app developers will resort to weird workarounds. 
And they already do, as I've mentioned.

Mobile Ads SDK Forum Advisor

unread,
Jul 11, 2023, 7:08:00 PM7/11/23
to lbl...@gmail.com, google-adm...@googlegroups.com
Hi Liran,


Thank you for the further details. I have made the feature request, and we are considering the best way to improve this restriction.

Liran Barsisa

unread,
Nov 8, 2023, 6:24:37 AM11/8/23
to Google Mobile Ads SDK Developers
Is it possible and official now, at least for native ads, perhaps?
"
You can preload native ads with loadAds() https://developers.devsite.corp.google.com/admob/android/native#loadads.
"

But I can't reach the link that was provided there, as it's only for people who work at Google, it seems...


mianha...@gmail.com

unread,
Nov 8, 2023, 12:31:07 PM11/8/23
to Google Mobile Ads SDK Developers
i am also looking for this feature , this will be a huge help for developers that are showing ads on an overlay. please implement this feature.

Mobile Ads SDK Forum Advisor

unread,
Nov 8, 2023, 1:20:11 PM11/8/23
to mianha...@gmail.com, google-adm...@googlegroups.com
Hi,

Thank you for reaching out. We are still looking into adding this functionality. We will let you know if we need further input.

Thanks,
Nick

ref:!00D1U01174p.!5004Q02mWO1y:ref
Reply all
Reply to author
Forward
0 new messages