Reputation: 43
For SDK versions earlier than 20.0.0 We can check if Interstitial is loading with this code:
private InterstitialAd mInterstitialAd; mInterstitialAd.isLoading();
For SDK version 20.0.0 We can only check if Interstitial is loaded with this code:
InterstitialAd.load(this,"ca-app-pub-3940256099942544/1033173712", adRequest, new InterstitialAdLoadCallback() { @Override public void onAdLoaded(@NonNull InterstitialAd interstitialAd) { mInterstitialAd = interstitialAd; Log.i(TAG, "onAdLoaded"); } });
Is there a method to check if Interstitial ad is loading in SDK version 20.0.0 ?
Upvotes: 1
Views: 949
Reputation: 167
private boolean isLoaded = false;
private void loadAd(){
isLoaded = false;
InterstitialAd.load(this,"ca-app-pub-3940256099942544/1033173712", adRequest,
new InterstitialAdLoadCallback() {
@Override
public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
mInterstitialAd = interstitialAd;
isLoaded = true;
Log.i(TAG, "onAdLoaded");
}
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
isLoaded = false;
Log.i(TAG, "Loading ad failed");
}
});
}
Upvotes: 1
Reputation: 644
It seems there is no built-in method to do that, but you can easily do:
private boolean isLoaded = false;
private void loadAd(){
InterstitialAd.load(this,"ca-app-pub-3940256099942544/1033173712", adRequest,
new InterstitialAdLoadCallback() {
@Override
public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
mInterstitialAd = interstitialAd;
isLoaded = true;
Log.i(TAG, "onAdLoaded");
}
});
}
And then simply get the value of isLoaded
.
Upvotes: 1