Display rewarded ad on Android

Display a rewarded ad

val rewardedAd = AdropRewardedAd(context, "YOUR_UNIT_ID")
rewardedAd.rewardedAdListener = object : AdropRewardedAdListener {
    override fun onAdReceived(ad: AdropRewardedAd) {
        Log.d("Adrop", "rewarded ad received ${ad.unitId}")
        ad.show()
    }
    
    override fun onAdFailedToReceive(ad: AdropRewardedAd, errorCode: AdropErrorCode) {
        Log.d("Adrop", "failed to receive $errorCode")
    }
    
    override fun onAdFailedToShowFullScreen(ad: AdropRewardedAd, errorCode: AdropErrorCode) {
        Log.d("Adrop", "failed to show full screen $errorCode")
    }
    ...
}
rewardedAd.load()

...
// call show function when the ad needs to be displayed.
rewardedAd.show(activity) { type, amount ->
    Log.d("ADROP", "earn handler $type, $amount")
}

Destroy

When you are done showing your AdropRewardedAd, you should destroy it so that the ad is properly garbage collected.

rewardedAd.destroy()

Last updated