Rewarded Ads are loaded automatically. You can observe ad loading events by specifying the delegate:
Java Kotlin
Copy Rewarded rewarded = new Rewarded( this ) ;
rewarded . setLoadDelegate ( this );
Copy
val rewarded: Rewarded ? = Rewarded ( this )
rewarded. setLoadDelegate (loadDelegate)
The delegate should implement the following methods:
Java Kotlin
Copy @ Override
public void didLoad( AdInfo adInfo) {
print( "Rewarded - didLoadAd. AdInfo: " + adInfo)
}
@ Override
public void didFailToLoad( AdInfo adInfo , Error error) {
print( "Rewarded - didFailToLoadAd. AdInfo:" + adInfo + " Error: " + error . getLocalizedMessage())
}
Copy override fun didLoad (adInfo: AdInfo ?) {
print ( "Rewarded - didLoadAd. AdInfo: $adInfo" )
}
override fun didFailToLoad (adInfo: AdInfo ?, error: Error ) {
print ( "Rewarded - didFailToLoadAd. AdInfo: $adInfo. Error: ${ error. getLocalizedMessage () } " )
}
Showing a Rewarded Ad
To show a rewarded ad, call showWithDelegate
method of the Rewarded
class:
Java Kotlin
Copy rewarded . showWithDelegate (Activity , showDelegate);
Copy rewarded. showWithDelegate (Activity, showDelegate)
The delegate should implement the following methods:
Java Kotlin
Copy @ Override
public void didDisplayAd( AdInfo adInfo) {
System . out . println ( "Rewarded - didDisplayAd. AdInfo:" + adInfo)
}
@ Override
public void didClickAd( AdInfo adInfo) {
System . out . println ( "Rewarded - didDisplayAd. AdInfo:" + adInfo );
}
@ Override
public void didHideAd( AdInfo adInfo) {
System . out . println ( "Rewarded - didHideAd. AdInfo:" + adInfo );
}
@ Override
public void didFailToDisplayAd( AdInfo adInfo , Error error) {
System . out . println ( "Rewarded - didFail toDisplayAd. AdInfo:" + adInfo + error . getLocalizedMessage ());
}
@ Override
public void allNetworksDidFailToDisplayAd() {
System . out . println ( "Rewarded - allNetworksDidFailToDisplayAd." );
}
@ Override
public void didRewardUser() {
System . out . println ( "Rewarded - didRewardUser" );
}
Copy override fun didDisplayAd (adInfo: AdInfo ?) {
print ( "Rewarded - didDisplayAd. AdInfo: $adInfo" )
}
override fun didClickAd (adInfo: AdInfo ?) {
print ( "Rewarded - didClickAd. AdInfo: $adInfo" )
}
override fun didHideAd (adInfo: AdInfo ?) {
print ( "Rewarded - didHideAd. AdInfo: $adInfo" )
}
override fun didFailToDisplayAd (adInfo: AdInfo ?, error: Error ) {
print ( "Rewarded - didFail toDisplayAd. AdInfo: $adInfo. Error: ${ error. getLocalizedMessage () } " )
}
override fun allNetworksDidFailToDisplayAd () {
print ( "Rewarded - allNetworksDidFailToDisplayAd." )
}
override fun didRewardUser () {
print ( "Rewarded - didRewardUser" )
}
Stopping and Starting Auto-Load
By default, Rewarded preload ads before any manual load attempt. So a Rewarded can use already preloaded ads instead of waiting on a manual load call to load new ads. To disable this feature you need to call the following method:
Java Kotlin
Copy rewarded . setAutoload ( false );
Copy rewarded. setAutoload ( false )
Once you disable autoload, you should load ads manually every time you need them to show:
Last updated 5 months ago