AMP Android SDK

AMP player

Google IMA / DAI

The following document describes how to implement Google IMA module from AMP Android SDK.


Before you continue be aware that AMP Android SDK can be integrated with different approaches:

  • AMP Basic Integration: AMP Android SDK has a standard API to implement all features. AMP Basic Integration. It requires more code development and gives more freedom. For example: it allows UI control customization, rebuild the UI Controls completely, integration of Server Side Ad Insertion like DAI and Client Side Ad Insertion like IMA at the same time.
  • AMP Player Wrapper Integration: AMP Android SDK has a Wrapper module called AmpPlayer module. This module simplifies the implementation even further. It is intended for customers who want a quick integration, with almost no customizations and a default UI. The AMP Player module unifies and coordinates all the different plugins we provide: playback, UI (scrubbar, buttons and events), Close Captions, ads and analytics. With this new module we are saving the developer most integration effort, by providing a single drag and drop plugin that will provide production quality results in a matter of a few minutes.

Reach out to us at with any questions or concerns.


The rest of this guide assumes you have successfully integrated AMP’s Core (you are able to play back a video): Basic Integration

Getting started

For reference, check the IMA Sample Android Studio sample project in the release package. To integrate the plugin into your app, you need to:

1) Copy the amp-ads-google-ima.jar to your project’s /libs folder.

2) Add the following line in the runnable module build.gradle file:

    api ''

3) In the Activity where playback is handled, import the following Java packages:


4) There are two possible IMAAdsPlugins, for client and server side ads respectively:

    private AmpIMAManager adsComponent;
    private AmpDAIManager adsComponent;

Depending on you business case, you could use one or the other, or both at the same time.

5) The initialization of those objects, depends on the specific type:

        adsComponent = IMA.create(this).buildClientSideManager();
        adsComponent = IMA.create(this).buildServerSideManager();

You should also configure them with their respective setVideoPlayerContainer() method

Optionally, you could also call addEventsListener() if needed. More details on the section below.

6) Configure the AdsComponent object when the onResourceReady(MediaResource resource) callback is triggered as follows:

    public void onResourceReady(MediaResource resource) {

7) Add the following line to the onDestroy() method of the Activity’s life cycle:

    public void onDestroy(){


You can add the following implementation to the onResume() and onPause() methods of the Activity’s life cycle, to implement automatic pause and recovery of the Ads in case the App implementing the Ads loses its foreground status.

    @Override public void onPause() { 

    @Override public void onResume() { 


You can create and register your own<GoogleAdsInfo>, in case you need to be notified of the following events:

	void onListenerRegistered();
	void onAdsInitialized();
	void onAdRequest();
	void onAdsLoaded(AdsCount adsCount);
	void onAdsStarted(T ad);
	void onAdsEnded();
	void onAllPostrollsEnded();
	void onAdsPaused();
	void onAdsResumed();
	void onAdBreakStarted();
	void onAdBreakEnded();
	void onAdsTrackProgress(int progress); //First quartile (0), midpoint (1), third quartile (2) and completed (3)
	void onAdsPlayheadUpdate(int seconds);
	void onAdsError(String reason);
	void onPauseContentRequested();
	void onResumeContentRequested();
	void onAdsTapped();
	void onAdSkipped();
	void onAdEvent();
	void onAdBufferingStarted();
	void onAdBufferingEnded();

There might be certain situations where IMA does not report some of the above; therefore, AMP won’t be able to report them in turn.

If you have further questions or comments, reach out to us via