Search code examples
androidinterstitial

Load Interstitial Ad in anctivity


In my app, after integrating Interstitial Ad, ads are loading fine.

Now i want that the activity where the ad is showing should not display ad every-time when the user is opening the activity otherwise it will be annoying for the user to use the app.

For the same user, if he is opening that activity then the ratio should be suppose if the user is opening the activity 5 times then 2 times he should see the ad.

Is this possible to implement. kindly suggest


Solution

  • declare public static int count=0;in activity where you start your intent to go in activity where you want to show ad

    now put this code

    you__activityname_where_count_declare.count++;
    
    if(you__activityname_where_count_declare.count==5)
      {
        you__activityname_where_count_declare.count=0;
        your_ad_method.ShowInterstitialAds();
      }
    

    it will show 1 time ad in 5 time visit