0

I am using chartboost interstitial in my android app and able to show interstitial ads using their android sdk.

The statement which shows the ad is:

this.cb.showInterstitial();

My question is that by using Java code, how can I randomize this display of ad so that users don't always see the ad but only at random times.

  • You want the Ad to not show (to be shown for example every 1 hour) or you want to Randomize the shown Ad? The title of the question deffers from the description and is somehow misleading. – g00dy Jun 28 '13 at 07:07
  • looking to show the ad when user clicked on a list item but then not show the ad every time he/she clicks the list item but showing it say 40% of the time when user clicked any of the list item – Piyush-Ask Any Difference Jun 28 '13 at 08:15
  • To have this 40% of the time, you must average the cliecks. Let's say I'm clicking 100 times on those, I'll receive the Ad 40 times, but if you click 10 times on the list items, you'll get them 4 times. That's the tough part. If you know that number (I can not evaluate it, ut you can, because only you know how often those clicks may occur), then you can assess what this 40% of the time really means. – g00dy Jun 28 '13 at 08:19
  • You can perform this calculation on the go. When the user is using the application, you can at first show the Ad on every two clicks, then after some use of the App, you'll get how ofter the user cliecks on the list views and evaluate the number of clicks, then calculate the number of shown Ads, by multiplying the clicks to 40%. – g00dy Jun 28 '13 at 08:23

1 Answers1

0
randomAdPopup() async {

initializeInterstitialAd();

List adTimeIntervalsList = [
  72,
  162,
  210,
  234,
  270,
];
var random = Random();
int randomNumber = random.nextInt(adTimeIntervalsList.length);

print(
    'ad coming in ${adTimeIntervalsList[randomNumber]} ****   AD  **');


Timer.periodic(Duration(seconds: adTimeIntervalsList[randomNumber]),
    (timer) async {
  initializeInterstitialAd();

  if (isInterstitialAdLoaded) {
    await interstitialAd.show();
  }
});
}
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 18 '22 at 07:52