Loading a Rewarded Ad
To load a rewarded ad, first obtain an instance of a MaxRewardedAd
object that corresponds to your rewarded ad unit.
Then call that object’s loadAd()
method.
Implement MaxRewardedAdListener
so that you are notified when your ad is ready.
This also notifies you of other ad-related events.
public class ExampleActivity extends Activity
implements MaxRewardedAdListener
private MaxRewardedAd rewardedAd ;
private int retryAttempt ;
rewardedAd = MaxRewardedAd . getInstance ( " «ad-unit-ID» " , getApplicationContext () ) ;
rewardedAd . setListener ( this ) ;
public void onAdLoaded ( final MaxAd maxAd )
// Rewarded ad is ready to be shown. rewardedAd.isReady() will now return 'true'
public void onAdLoadFailed ( final String adUnitId , final MaxError error )
// Rewarded ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
long delayMillis = TimeUnit . SECONDS . toMillis ( ( long ) Math . pow ( 2 , Math . min ( 6 , retryAttempt ) ) ) ;
new Handler () . postDelayed ( new Runnable ()
public void onAdDisplayFailed ( final MaxAd maxAd , final MaxError error )
// Rewarded ad failed to display. AppLovin recommends that you load the next ad.
public void onAdDisplayed ( final MaxAd maxAd ) {}
public void onAdClicked ( final MaxAd maxAd ) {}
public void onAdHidden ( final MaxAd maxAd )
// rewarded ad is hidden. Pre-load the next ad
public void onUserRewarded ( final MaxAd maxAd , final MaxReward maxReward )
// Rewarded ad was displayed and user should receive the reward
class ExampleActivity : Activity(), MaxRewardedAdListener
private lateinit var rewardedAd: MaxRewardedAd
private var retryAttempt = 0.0
rewardedAd = MaxRewardedAd. getInstance ( " «ad-unit-ID» " , applicationContext )
rewardedAd. setListener ( this )
override fun onAdLoaded (maxAd: MaxAd)
// Rewarded ad is ready to be shown. rewardedAd.isReady() will now return 'true'
override fun onAdLoadFailed (adUnitId: String?, error: MaxError?)
// Rewarded ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
val delayMillis = TimeUnit.SECONDS. toMillis ( Math. pow ( 2.0 , Math. min ( 6.0 , retryAttempt ) ). toLong () )
Handler (). postDelayed ( { rewardedAd. loadAd () }, delayMillis )
override fun onAdDisplayFailed (ad: MaxAd?, error: MaxError?)
// Rewarded ad failed to display. AppLovin recommends that you load the next ad.
override fun onAdDisplayed (maxAd: MaxAd) {}
override fun onAdClicked (maxAd: MaxAd) {}
override fun onAdHidden (maxAd: MaxAd)
// rewarded ad is hidden. Pre-load the next ad
override fun onUserRewarded (maxAd: MaxAd, maxReward: MaxReward)
// Rewarded ad was displayed and user should receive the reward
Showing a Rewarded Ad
To show a rewarded ad, call showAd( this )
on the MaxRewardedAd
object you created.
if ( rewardedAd . isReady () )
// `this` is the activity that will be used to show the ad
rewardedAd . showAd ( this ) ;
if ( rewardedAd.isReady )
// `this` is the activity that will be used to show the ad
Accessing the Amount and Currency for a Rewarded Ad
To access the reward amount and currency, override the onUserRewarded()
callback:
public void onUserRewarded ( final MaxAd ad, final MaxReward reward )
System . out . println ( " Rewarded user: " + reward . getAmount () + " " + reward . getLabel () ) ;
override fun onUserRewarded (ad: MaxAd?, reward: MaxReward?)
System.out. println ( "Rewarded user: " + reward !! . getAmount () + " " + reward. getLabel () )
S2S Rewarded Callbacks
You can receive callbacks to your currency server.
To learn how, see the MAX S2S Rewarded Callback API guide .
Then update the Server Side Callback URL in your Edit Ad Unit page.
Setting the Amount and Currency for a Rewarded Ad
To set the reward amount and currency:
Click Add S2S Reward Callback in your Edit Ad Unit page:
Add the Server Side Callback URL , Reward Amount , and Rewarded Currency Name :