Search code examples
androidadmobads

Show a custom image when AdMob Ad is blocked or not available


I had the issue to display an image on AdMob Ad's when no Ad could be loaded or is blocked by the user. That occurs when the user has no internet connection for example or uses software to block ads.


Solution

  • I found the following answer to my question:

    http://googleadsdeveloper.blogspot.de/2012/06/show-custom-image-when-no-admob-ad-is.html

    The link describes basically that you can react if the ad fails to load to show your own image using the method:

    ...
    
    @Override
    public void onFailedToReceiveAd(Ad ad, ErrorCode code)
    {
        adView.setVisibility(View.GONE);
        customView.setVisibility(View.VISIBLE);
    
    ...
    

    I hope it's useful to some others.