📖
SDKs Integration
  • Quick Start
  • 🤖Android
    • Android SDK Integration
      • Banner Ads
      • Interstitial Ads
      • Rewarded Ads
  • 🍏iOS
    • iOS SDK Integration
      • Banner Ads
      • Interstitial Ads
      • Rewarded Ads
  • Frequently Asked Questions
  • Contact us
  • Documentation
Powered by GitBook
On this page

Was this helpful?

  1. Android
  2. Android SDK Integration

Rewarded Ads

First of all, you need to create a AdstronomicAdsRewarded object and init it (with your application context in parameter). After this, you have two possibilities:

  • Display as quickly as possible the ad after loading it. For this, you can simply call the method Adstronomic.loadAndShow with the app context and the ad object as parameters.

  • Just load the ad in the background by calling the method loadAd. And, when you want to show the ad (after a specific event - For example: click on a button) you can do it with the method show.

So, for example:

AdstronomicAdsRewarded rewardedAd = new AdstronomicAdsRewarded(getApplicationContext());
Adstronomic.loadAndShow(this, rewardedAd);

or

AdstronomicAdsRewarded rewardedAd = new AdstronomicAdsRewarded(getApplicationContext());
rewardedAd.loadAd();

...

// Call when a button is pressed for example
if (rewardedAd.isAdLoaded()) {
    rewardedAd.show();
}

Listener

If you want to unlock reward or detect when an error occurred (ads not available because of internet connection issue), you can add a listener in order to execute your custom logic. For this, see the following example:

AdListener listener = new AdListener() {
    @Override
    public void onAdLoadFailed(@NotNull Exception exception) {

    }

    @Override
    public void onAdLoaded() {

    }

    @Override
    public void onAdClosed() {
        System.out.println("Event: onAdClosed");
    }

    @Override
    public void onAdShown() {

    }

    @Override
    public void onApplicationLeft() {

    }
};
rewardedAd.setAdListener(listener);

Each event is self explanatory. For example, if you want to give a reward to the player, execute this code in onAdClosed.

PreviousInterstitial AdsNextiOS SDK Integration

Last updated 4 years ago

Was this helpful?

🤖