In this tutorial we show how to integrate the ArenaDaemon's ADV feature into an Android application.

More in depth, we are going to show how to display advertising banners and videos.


We assume that the developer already owns an account into the ArenaDaemon web platform and

owns the knowledge for creating a new application and retrieving the correspondent appKey.

For more information about how to create a developer account and for setup a new application,

please refer to the chapter "Create an appKey".


Create a new Android project and include the SDK as shown in chapter SDK Installation and setup.


The next step is to create an Activity (we'll give it the name 'MainActivity') in which

we'll load a banner and a clip.


Before doing any action with the daemons, the local player needs to be authenticated so we need

to add the following code to the MainActivity class :



protected void onCreate(Bundle savedInstanceState) {





        // container view for banner

        bannerContainer = (RelativeLayout) findViewById(;


        // container view for clip

        clipContainer = (RelativeLayout) findViewById(;


        // buttons

        startStopBannerRotationButton = (Button)





        getAdClipButton = (Button) findViewById(;



        // arena listener

        listener = new BDArenaConnectorListener(this);


        // user authentication - put your key in Strings.xml


                                                              getResources().getString(R.string.arena_key),                                                                     true);




        // enable rotation for 320x53 banner format









public void onResume() {



        // register the listener for callbacks



        // enable rotation for 320x53 banner format

        banner = 










public void onPause(){



        // unregister the listener





Please note that we have also created two Button :

  • The first one (startStopBannerRotationButton) will manage the auto refresh status related to the 320x53 banner display.
  • The second one (getAdClipButton) will set the target View in which the SDK will load and show an ad clip.

Moreover, in the onResume method, we'll place into banner object, as subview, the banner's view.


Now we need to add the code for the actions triggered by the two Button:




public void onClick(View v) {

        if(v == startStopBannerRotationButton) {

                if(BDArenaConnector.getInstance().advIsBannerRotationActive()) {


                        // stop banner rotation







                else {

                        // start banner rotation







        else if(v == getAdClipButton) {

                if(BDArenaConnector.getInstance().isLocalPlayerAuthenticated()) {


                        // if you like to customize adClip components appearance,

                        // create a BDArenaAdClipConfigData object

                        BDArenaAdClipConfigData config = new BDArenaAdClipConfigData();


                        // for the countdownText property you can use

                        // [remaining], [duration] and [percent] macros...


                                "My app will start in [remaining] seconds ([percent]% played)..."


                        config.setClickThruAlertTitle("Thanks for the click!");

                        config.setClickThruAlertMessage("Do you want to open the website?");


                        config.setClickThruAlertCancelButtonTitle("No, thanks");


                        // make call for clip


                                                                                             clipContainer, config);





                        Toast.makeText(this, getResources().getString(R.string.error_auth), 






Tapping the 'get ad clip' button, the app tells the SDK to retrieve a clip.

When an ad clip is successfully retrieved, the SDK notifies the event by calling

the arenaAdvConnectorClipReadyToPlay method of the BDArenaConnectorListener.


If this event occurs, the developer can start the clip playback by calling advPlayAdClipInView




public void arenaAdvConnectorClipReadyToPlay(RelativeLayout targetView) {





In order to be notified when the clip ends, the developer needs to override the

arenaAdvConnectorClipDidFinishPlayback method of BDArenaConnectorListener.




public void arenaAdvConnectorClipDidFinishPlayback(

        RelativeLayout targetView,

        int reason) {





For the action getGhostOver we'll set :


else if(v == getGhostOverButton) {


        if(BDArenaConnector.getInstance().isLocalPlayerAuthenticated()) {







               //handle error





Tapping the 'get GhostOver' button, the app tells the SDK to retrieve a GhostOver ad.

When an ad is successfully retrieved, the SDK notifies the event by calling

the arenaConnectorGhostOverReadyToPlay method of the BDArenaConnectorListener interface.


If this event occurs, the developer can start the clip playback by calling advPlayGhostOverAd


public void arenaAdvConnectorGhostOverReadyToPlay(){


       // a GhostOver ad has been found... just play it!





In order to be notified when the ad ends, the developer needs to override the

arenaConnectorGhostOverDidReachCompletionarenaConnectorGhostOverDidBreak or


methods of BDArenaConnectorListener interface.



NOTE : If the developer needs to support older version of Android API (prior to v. 10), he has to manage programmatically the device orientation changes to prevent Layout reload.


In order to achieve that, the developer needs to set orientation|screenSize for the attribute android:configChanges, within the AndroidManifest.xml file, for each Activity that will use the

SDK's ad clip the feature :







        android:theme="@style/AppTheme" >




            android:label="@string/app_name" >


                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />







Once setup the manifest file, the developer needs to override onConfigurationChanged method

in order to correctly resize the ad clip view :




public void onConfigurationChanged(Configuration newConfig) {



        // swap width and height on orientation change (only needed for API <= 10)


                if(clipContainerWidth > 0 && clipContainerHeight > 0) {

                        Log.i("ARENA DAEMON", "ORIENTATION CHANGED");












The application will look like :






Sample project

Download the sample project for this tutorial.