Google is committed to advancing racial equity for Black communities. See how.

AdManagerAdView

public final class AdManagerAdView extends BaseAdView

The View to display banner ads for use with Google Ad Manager. The ad size and ad unit ID must be set prior to calling BaseAdView.loadAd(AdRequest).

Sample code:

 public class MyActivity extends Activity {
     private AdManagerAdView adManagerAdView;

     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

         LinearLayout layout = new LinearLayout(this);
         layout.setOrientation(LinearLayout.VERTICAL);

         // Create a banner ad. The ad size and ad unit ID must be set before calling loadAd.
         adManagerAdView = new AdManagerAdView(this);
         adManagerAdView.setAdSize(AdSize.SMART_BANNER);
         adManagerAdView.setAdUnitId("myAdUnitId");

         // Add the AdManagerAdView to the view hierarchy.
         layout.addView(adManagerAdView);

         // Start loading the ad.
         adManagerAdView.loadAd(new AdManagerAdRequest.Builder().build());

         setContentView(layout);
     }

     @Override
     public void onResume() {
         super.onResume();

         // Resume the AdManagerAdView.
         adManagerAdView.resume();
     }

     @Override
     public void onPause() {
         // Pause the AdManagerAdView.
         adManagerAdView.pause();

         super.onPause();
     }

     @Override
     public void onDestroy() {
         // Destroy the AdManagerAdView.
         adManagerAdView.destroy();

         super.onDestroy();
     }
 }

XML Attribute Summary

Inherited XML Attribute Summary

Inherited Constant Summary

Inherited Field Summary

Public Constructor Summary

AdManagerAdView(Context context)
Constructs an AdManagerAdView from code.
AdManagerAdView(Context context, AttributeSet attrs)
Constructs an AdManagerAdView from an XML layout.
AdManagerAdView(Context context, AttributeSet attrs, int defStyle)
Constructs an AdManagerAdView from an XML layout.

Public Method Summary

AdSize[]
getAdSizes()
Returns the ad sizes supported by this AdManagerAdView.
AppEventListener
VideoController
getVideoController()
Returns the VideoController for this ad view.
VideoOptions
getVideoOptions()
Returns the VideoOptions for this ad view.
void
loadAd(AdManagerAdRequest adManagerAdRequest)
Loads an ad.
void
recordManualImpression()
Records a manual impression.
void
setAdSizes(AdSize... adSizes)
Sets the supported sizes of the banner ad.
void
void
setManualImpressionsEnabled(boolean manualImpressionsEnabled)
Indicates whether you intend to record impressions manually for this AdManagerAdView.
void
setVideoOptions(VideoOptions videoOptions)
Sets the VideoOptions for this ad view.

Inherited Method Summary