Sid Go
Sid Go

Reputation: 2151

How to completely hide AdView if the request failed (maybe offline)?

I want the AdView to be set to GONE (so that user don't see large empty space) if after the 60 sec. refresh, it failed to load an ad (maybe offline?). But I still want it to keep on refreshing until it succeeds then make it visible again.

I'm being straight to the point. Thank you.

Upvotes: 1

Views: 287

Answers (1)

Sasi Kumar
Sasi Kumar

Reputation: 13348

Use AdListener

public abstract class AdListener {
public void onAdLoaded();
public void onAdFailedToLoad(int errorCode); //hide adview here
public void onAdOpened();
public void onAdClosed();
 public void onAdLeftApplication();
  }

A separate class extending AdListener may be defined, or you can choose to inline an AdListener object:

adView.setAdListener(new AdListener() {
@Override
public void onAdFailedToLoad(int errorCode) {
 // hide or refresh adview 
}
});

read more here

Upvotes: 1

Related Questions