Skip to content

Instantly share code, notes, and snippets.

@prakashpun
Created January 7, 2018 09:12
Show Gist options
  • Save prakashpun/9d18fc00ab7b89b2c90c5170f8bff0c7 to your computer and use it in GitHub Desktop.
Save prakashpun/9d18fc00ab7b89b2c90c5170f8bff0c7 to your computer and use it in GitHub Desktop.
methods corresponding to the events in a rewarded video ad's lifecycle.
mRewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {
@Override
public void onRewarded(RewardItem rewardItem) {
Toast.makeText(getBaseContext(), "You get reward of : "+rewardItem.getAmount(), Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdLoaded() {
Toast.makeText(getBaseContext(), "Ad loaded.", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdOpened() {
Toast.makeText(getBaseContext(), "Ad opened.", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoStarted() {
Toast.makeText(getBaseContext(), "Ad started.", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdClosed() {
Toast.makeText(getBaseContext(), "Ad closed.", Toast.LENGTH_SHORT).show();
mRewardedVideoAd.loadAd(getString(R.string.ad_unit_id), new AdRequest.Builder().build());
}
@Override
public void onRewardedVideoAdLeftApplication() {
Toast.makeText(getBaseContext(), "Ad left application.", Toast.LENGTH_SHORT).show();
}
@Override
public void onRewardedVideoAdFailedToLoad(int i) {
Toast.makeText(getBaseContext(), "Ad failed to load.", Toast.LENGTH_SHORT).show();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment