Reputation: 16825
I try to display a banner / text if the AdView fails to load (because of AdBlock or anything else).
I tried different methods:
nothing works. Can anyone help me?
Upvotes: 1
Views: 1105
Reputation: 8931
You can implement the AdListener interface to listen for AdMob events.
public interface AdListener {
public void onReceiveAd(Ad ad);
public void onFailedToReceiveAd(Ad ad, AdRequest.ErrorCode error);
public void onPresentScreen(Ad ad);
public void onDismissScreen(Ad ad);
public void onLeaveApplication(Ad ad);
}
Then you will want your AdView to listen to the AdListener.
// Assuming AdView is named adView and this class implemented AdListener.
adView.setAdListener(this);
In particular, you will be interested in the the onFailedToReceiveAd callback. This called if AdMob failed to load an ad. If you implement this method, you can take appropriate action in your application when an ad is not returned.
Upvotes: 1