How can I make banner ads load only once in recyclerview?

99 views
Skip to first unread message

Muhammed

unread,
Feb 4, 2024, 4:28:49 AM2/4/24
to Google Mobile Ads SDK Developers
I have a recyclerview and I want to put a banner ad after every 10 items in it. However, if I do as in the official document, that is, if I pre-load the ads, this time the ad display rate decreases (I get a very low display rate around 20-30%).
Another method is to load the onCreateViewHolder or the holder containing the ad in the constructor. However, this time it only loads 1 ad at a time.
Another method is to load it in onBindViewHolder as in my example. However, this is not the right option because onLoading occurs when the creative leaves the screen while scrolling and enters it again, that is, the bind operation is performed again. I think this would also be a policy violation.
In short, all these solutions do not work. I want a different and correct method. I don't want the recyclerview to load over and over again when it scrolls.

This method is very old and pre-loading ads is not really correct. because if the user doesn't scroll to the end of the list, he won't get any views. While the match rate is 80-90%, the display rate remains at 20%. This is not true. Please bring a solution


TestActivity


public class TestActivity extends AppCompatActivity {
RecyclerView recyclerView;
TestAdapter testAdapter;
List<String> itemList = new ArrayList<>();

@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test_activity);

for (int i = 0; i < 200; i++) {
itemList.add("Item " + i);
if (i % 10 == 0) {
itemList.add(null);
}
}

recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));

testAdapter = new TestAdapter(itemList);
recyclerView.setAdapter(testAdapter);
}
}


TestAdapter


public class TestAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
List<String> itemList;
static final int CONTENT_TYPE = 0;
static final int AD_TYPE = 1;

public TestAdapter(List<String> itemList) {
this.itemList = itemList;
}

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (viewType == CONTENT_TYPE) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.test_item, parent, false);
return new ViewHolder(view);
} else {
View adView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_ad, parent, false);
return new AdRecyclerHolder(adView);
}
}

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof ViewHolder viewHolder) {
viewHolder.idText.setText(String.valueOf(position));
viewHolder.title.setText(itemList.get(position));
} else if (holder instanceof AdRecyclerHolder adHolder) {
AdRequest adRequest = new AdRequest.Builder().build();
adHolder.mAdView.loadAd(adRequest);
adHolder.mAdView.setAdListener(new AdListener() {
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
Log.e("TAG_AD", "onAdFailedToLoad");
super.onAdFailedToLoad(loadAdError);
}

@Override
public void onAdLoaded() {
Log.e("TAG_AD", "onAdLoaded");
}
});
}
}

@Override
public int getItemCount() {
return itemList.size();
}

@Override
public int getItemViewType(int position) {
if (itemList.get(position) == null) {
return AD_TYPE;
} else {
return CONTENT_TYPE;
}
}

public static class ViewHolder extends RecyclerView.ViewHolder {
TextView idText, title;

public ViewHolder(@NonNull View itemView) {
super(itemView);
idText = itemView.findViewById(R.id.id_text);
title = itemView.findViewById(R.id.title);
}
}

public static class AdRecyclerHolder extends RecyclerView.ViewHolder {
AdView mAdView;
public AdRecyclerHolder(@NonNull View itemView) {
super(itemView);
mAdView = itemView.findViewById(R.id.adView);
}
}
}

Mobile Ads SDK Forum Advisor

unread,
Feb 4, 2024, 10:36:53 PM2/4/24
to 4d756861...@gmail.com, google-adm...@googlegroups.com
Hi,

Thank you for contacting the Mobile Ads SDK Support team. 

To load ad perfectly and improve impression while scrolling i recommend to show ads when they are ready and about to become visible. Loading with prefetching technique, it might fail because of high frequency. You can use mediation platform also which increases the chance of finding a relevant ad and improves the overall fill rate. 

Please refer this recommended banner implementations guidelines.

This message is in relation to case "ref:!00D1U01174p.!5004Q02ryo6x:ref"

Thanks,
 
Google Logo Mobile Ads SDK Team


Muhammed

unread,
Feb 5, 2024, 4:37:56 AM2/5/24
to Google Mobile Ads SDK Developers
Could you please update the example here? because it pre-loads but no impressions, it gets about 20% impressions.

https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/BannerRecyclerViewExample/app/src/main/java/com/google/android/gms/example/bannerrecyclerviewexample/MainActivity.java

5 Şubat 2024 Pazartesi tarihinde saat 06:36:53 UTC+3 itibarıyla Mobile Ads SDK Forum Advisor şunları yazdı:

Muhammed

unread,
Feb 5, 2024, 10:37:58 AM2/5/24
to Google Mobile Ads SDK Developers
I opened a topic here. Could you please report it to the authorities? If the ad display rate is 20% and the match rate is 80-90%, it will probably cause deactivation by Google Admob. please inform me later

https://github.com/googleads/googleads-mobile-android-examples/issues/646

5 Şubat 2024 Pazartesi tarihinde saat 12:37:56 UTC+3 itibarıyla Muhammed şunları yazdı:

Mobile Ads SDK Forum Advisor

unread,
Feb 5, 2024, 10:57:37 AM2/5/24
to 4d756861...@gmail.com, google-adm...@googlegroups.com

Hi,

Thank you for getting back to us.

I will check with our team regarding your issue and one of my team members will reach out to you once we have an update on this. Meanwhile, your patience is highly appreciated.

Muhammed

unread,
Feb 8, 2024, 10:39:11 AM2/8/24
to Google Mobile Ads SDK Developers
https://github.com/googleads/googleads-mobile-android-examples/blob/master/java/advanced/BannerRecyclerViewExample/app/src/main/java/com/google/android/gms/example/bannerrecyclerviewexample/MainActivity.java

https://github.com/googleads/googleads-mobile-android-examples/blob/main/java/advanced/InlineAdaptiveBannerExample/app/src/main/java/com/google/android/gms/example/inlineadaptivebannerexample/MainActivity.java

Hello, the two examples here are identical.
"Inline Adaptive Banner" and "Banner RecyclerView"

The samples pre-load ads. As I mentioned on the subject, preloading reduces the ad viewing rate.
There is still no update for this. The repo is being updated but still no solution has been provided. Please provide solution.

Another problem is; When a search is made within the list, the ads are binded again. bring a solution to this.
I am waiting for a reply


5 Şubat 2024 Pazartesi tarihinde saat 18:57:37 UTC+3 itibarıyla Mobile Ads SDK Forum Advisor şunları yazdı:

Mobile Ads SDK Forum Advisor

unread,
Feb 8, 2024, 10:51:11 AM2/8/24
to 4d756861...@gmail.com, google-adm...@googlegroups.com

Hi,

Thank you for getting back to us.

Your concern is currently under investigation and we have no updates to provide at this time. However, please rest assured that our team is actively working on it. We appreciate your understanding and patience.

Muhammed

unread,
Feb 8, 2024, 11:59:35 AM2/8/24
to Google Mobile Ads SDK Developers
So when will a solution be found? What if my account gets banned? Many people said that their account received a warning due to low impression rate

8 Şubat 2024 Perşembe tarihinde saat 18:51:11 UTC+3 itibarıyla Mobile Ads SDK Forum Advisor şunları yazdı:

Mobile Ads SDK Forum Advisor

unread,
Feb 8, 2024, 3:54:29 PM2/8/24
to 4d756861...@gmail.com, google-adm...@googlegroups.com

Hi,

Thank you for getting back to us.

We do not have a specific time frame for the availability of this feature at the moment. Please be assured that our team is actively working on it. We appreciate your understanding and patience.

If your account gets banned, I would recommend that you reach out to the Product support team as they are better equipped to address your concern. This support channel can only best assist you with regards to direct Mobile Ads SDK implementation and technical issues.
 

Reply all
Reply to author
Forward
0 new messages