How to create an ADMOB Rewarded Interstitial Ad in Android Studio | Google Admob Rewarded Interstitial Ad Network

Now, we have to create a “Rewarded Interstitial Ad” in the MainActivity.java files that you can of your mobile app users.

first, we create a variable that includes “AD UNIT ID” and Rewarded Interstitial Ad.

private static final String AD_UNIT_ID = "ca-app-pub-3940256099942544/5354046379";
private static final String TAG = "RewardedInterstitialAdActivity";
private RewardedInterstitialAd rewardedInterstitialAd;

Now, we have initialized to MobileAds with the help of the Lamba Method.

MobileAds.initialize(
this,
initializationStatus -> loadRewardedInterstitialAd());

Now, we have to create a loadRewardedInterstitialAd under AppCompactActivity.

private void loadRewardedInterstitialAd() {
if (rewardedInterstitialAd == null) {
AdRequest adRequest = new AdRequest.Builder().build();
RewardedInterstitialAd.load(
RewardedInterstitialAdActivity.this,
AD_UNIT_ID,
adRequest,
new RewardedInterstitialAdLoadCallback() {
@Override
public void onAdLoaded(@NonNull RewardedInterstitialAd ad) {
rewardedInterstitialAd = ad;
Activity activityContext = RewardedInterstitialAdActivity.this;
rewardedInterstitialAd.show(activityContext,
rewardItem -> {
});
}

@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
rewardedInterstitialAd = null;
}
});
}
}

————— THANK YOU VERY MUCH —————

Scroll to Top