I have a RecyclerView
in which I have put the AdMob ad
.
I have written this code to show the ad having same Ad unit ID
at random positions in the recyclerview:
Random rand = new Random();
NativeExpressAdView adView = (NativeExpressAdView) itemView.findViewById(R.id.adView);
adView.setVisibility(View.GONE);
if (count >= random) {
random = rand.nextInt(3); // Reset the counter to random integer
count = 0;
adView.setVisibility(View.VISIBLE);
AdRequest request = new AdRequest.Builder()
.addTestDevice("********")
.addTestDevice("********")
.build();
adView.loadAd(request);
} else {
count++;
}
here's the xml part:
<com.google.android.gms.ads.NativeExpressAdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
ads:adUnitId="ca-app-pub-***/***"
ads:adSize="320x80">
</com.google.android.gms.ads.NativeExpressAdView>
So, I just want to know that is this a good practice or is there any policy violation or such thing in doing this?
Please let me know.