com.google.android.gms.ads.rewarded.RewardedAdCallback Java Examples
The following examples show how to use
com.google.android.gms.ads.rewarded.RewardedAdCallback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java From googleads-mobile-android-examples with Apache License 2.0 | 5 votes |
private void showRewardedVideo() { showVideoButton.setVisibility(View.INVISIBLE); if (rewardedAd.isLoaded()) { RewardedAdCallback adCallback = new RewardedAdCallback() { @Override public void onRewardedAdOpened() { // Ad opened. Toast.makeText(MainActivity.this, "onRewardedAdOpened", Toast.LENGTH_SHORT).show(); } @Override public void onRewardedAdClosed() { // Ad closed. Toast.makeText(MainActivity.this, "onRewardedAdClosed", Toast.LENGTH_SHORT).show(); // Preload the next rewarded ad. MainActivity.this.loadRewardedAd(); } @Override public void onUserEarnedReward(RewardItem rewardItem) { // User earned reward. Toast.makeText(MainActivity.this, "onUserEarnedReward", Toast.LENGTH_SHORT).show(); addCoins(rewardItem.getAmount()); } @Override public void onRewardedAdFailedToShow(int errorCode) { // Ad failed to display Toast.makeText(MainActivity.this, "onRewardedAdFailedToShow", Toast.LENGTH_SHORT) .show(); } }; rewardedAd.show(this, adCallback); } }
Example #2
Source File: MainActivity.java From googleads-mobile-android-examples with Apache License 2.0 | 5 votes |
private void showRewardedVideo() { showVideoButton.setVisibility(View.INVISIBLE); if (rewardedAd.isLoaded()) { RewardedAdCallback adCallback = new RewardedAdCallback() { @Override public void onRewardedAdOpened() { // Ad opened. Toast.makeText(MainActivity.this, "onRewardedAdOpened", Toast.LENGTH_SHORT).show(); } @Override public void onRewardedAdClosed() { // Ad closed. Toast.makeText(MainActivity.this, "onRewardedAdClosed", Toast.LENGTH_SHORT).show(); // Preload the next video ad. MainActivity.this.loadRewardedAd(); } @Override public void onUserEarnedReward(RewardItem rewardItem) { // User earned reward. Toast.makeText(MainActivity.this, "onUserEarnedReward", Toast.LENGTH_SHORT).show(); addCoins(rewardItem.getAmount()); } @Override public void onRewardedAdFailedToShow(int errorCode) { // Ad failed to display Toast.makeText(MainActivity.this, "onRewardedAdFailedToShow", Toast.LENGTH_SHORT) .show(); } }; rewardedAd.show(this, adCallback); } }