Class LevelPlayRewardedAd
-
- All Implemented Interfaces:
public final class LevelPlayRewardedAdClass responsible for handling the APIs, callbacks and overall operations of a rewarded ad.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classLevelPlayRewardedAd.ConfigRewarded ad configurations
Use the builder to construct a configuration
-
Constructor Summary
Constructors Constructor Description LevelPlayRewardedAd(String adUnitId)Initializes a rewarded ad. LevelPlayRewardedAd(String adUnitId, LevelPlayRewardedAd.Config config)Initializes a rewarded ad with configuration.
-
Method Summary
Modifier and Type Method Description final StringgetAdUnitId()final StringgetAdId()final UnitloadAd()Loads a rewarded ad. final UnitshowAd(Activity activity, String placementName)Shows the ad. final UnitshowAd(Activity activity)Shows the ad. final BooleanisAdReady()Checks if the ad is ready. final UnitsetListener(LevelPlayRewardedAdListener listener)Sets a listener for the ad callbacks. final LevelPlayRewardgetReward(String placement)Retrieves the reward associated with the ad. final LevelPlayRewardgetReward()Retrieves the reward associated with the ad. final static BooleanisPlacementCapped(String placementName)Checks if the placement is capped. -
-
Constructor Detail
-
LevelPlayRewardedAd
LevelPlayRewardedAd(String adUnitId)
Initializes a rewarded ad.- Parameters:
adUnitId- The ad unit identifier.
-
LevelPlayRewardedAd
LevelPlayRewardedAd(String adUnitId, LevelPlayRewardedAd.Config config)
Initializes a rewarded ad with configuration.- Parameters:
adUnitId- The ad unit identifier.config- The ad unit configuration.
-
-
Method Detail
-
getAdUnitId
final String getAdUnitId()
-
loadAd
final Unit loadAd()
Loads a rewarded ad. The listener will send a onAdLoaded() or onAdLoadFailed() callback. The callbacks will be invoked on the main thread.
-
showAd
@JvmOverloads() final Unit showAd(Activity activity, String placementName)
Shows the ad. The listener will send a onAdDisplayed() or onAdDisplayFailed() callback. The callbacks will be invoked on the main thread.
- Parameters:
activity- The activity where the ad will be shown.placementName- The placement name for the ad.
-
showAd
@JvmOverloads() final Unit showAd(Activity activity)
Shows the ad. The listener will send a onAdDisplayed() or onAdDisplayFailed() callback. The callbacks will be invoked on the main thread.
- Parameters:
activity- The activity where the ad will be shown.
-
isAdReady
final Boolean isAdReady()
Checks if the ad is ready. Showing an ad that is not ready will result in a show failure. When calling to the show api with placement, make sure to verify that placement isn't capped via isPlacementCapped().
- Returns:
True if the ad is ready, false otherwise.
-
setListener
final Unit setListener(LevelPlayRewardedAdListener listener)
Sets a listener for the ad callbacks. The callbacks will be invoked on the main thread.
- Parameters:
listener- The listener to set.
-
getReward
@JvmOverloads() final LevelPlayReward getReward(String placement)
Retrieves the reward associated with the ad.
Use this method to obtain the reward configured for the ad unit or placement. The placement-specific reward takes precedence over the ad unit reward when a valid placement name is provided.
- Parameters:
placement- The placement name to retrieve the reward for, ornullto use the ad unit's reward.- Returns:
A LevelPlayReward object. Returns an empty reward on failures (
name: ""andamount: 0).
-
getReward
@JvmOverloads() final LevelPlayReward getReward()
Retrieves the reward associated with the ad.
Use this method to obtain the reward configured for the ad unit or placement. The placement-specific reward takes precedence over the ad unit reward when a valid placement name is provided.
- Returns:
A LevelPlayReward object. Returns an empty reward on failures (
name: ""andamount: 0).
-
isPlacementCapped
final static Boolean isPlacementCapped(String placementName)
Checks if the placement is capped.
- Parameters:
placementName- The placement name to check.- Returns:
True if the placement is capped, false otherwise.
-
-
-
-